aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-07-12 10:53:46 +0200
committerChocobozzz <me@florianbigard.com>2023-07-12 10:56:07 +0200
commitd959b763f089ed4c1087aa4aeb824a8ef6743111 (patch)
treef4b5e77757fde022c91e415906bcf4619f8ec31c /server/initializers
parent88cde4392a27d5d37685a471f9bf83d537282c43 (diff)
downloadPeerTube-d959b763f089ed4c1087aa4aeb824a8ef6743111.tar.gz
PeerTube-d959b763f089ed4c1087aa4aeb824a8ef6743111.tar.zst
PeerTube-d959b763f089ed4c1087aa4aeb824a8ef6743111.zip
Avoid duplicate runner names
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/initializers/migrations/0795-duplicate-runner-name.ts24
2 files changed, 25 insertions, 1 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 03ae94d35..e09f0e3c6 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -27,7 +27,7 @@ import { CONFIG, registerConfigChangedHandler } from './config'
27 27
28// --------------------------------------------------------------------------- 28// ---------------------------------------------------------------------------
29 29
30const LAST_MIGRATION_VERSION = 790 30const LAST_MIGRATION_VERSION = 795
31 31
32// --------------------------------------------------------------------------- 32// ---------------------------------------------------------------------------
33 33
diff --git a/server/initializers/migrations/0795-duplicate-runner-name.ts b/server/initializers/migrations/0795-duplicate-runner-name.ts
new file mode 100644
index 000000000..dd15a8157
--- /dev/null
+++ b/server/initializers/migrations/0795-duplicate-runner-name.ts
@@ -0,0 +1,24 @@
1import * as Sequelize from 'sequelize'
2
3async function up (utils: {
4 transaction: Sequelize.Transaction
5 queryInterface: Sequelize.QueryInterface
6 sequelize: Sequelize.Sequelize
7}): Promise<void> {
8 const { transaction } = utils
9
10 const query = 'DELETE FROM "runner" r1 ' +
11 'USING (SELECT MIN(id) as id, "name" FROM "runner" GROUP BY "name" HAVING COUNT(*) > 1) r2 ' +
12 'WHERE r1."name" = r2."name" AND r1.id <> r2.id'
13
14 await utils.sequelize.query(query, { transaction })
15}
16
17function down (options) {
18 throw new Error('Not implemented.')
19}
20
21export {
22 up,
23 down
24}