aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/initializers/migrations/0190-video-comment-unique-url.ts23
2 files changed, 24 insertions, 1 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index a88f9642c..03828f54f 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -12,7 +12,7 @@ let config: IConfig = require('config')
12 12
13// --------------------------------------------------------------------------- 13// ---------------------------------------------------------------------------
14 14
15const LAST_MIGRATION_VERSION = 185 15const LAST_MIGRATION_VERSION = 190
16 16
17// --------------------------------------------------------------------------- 17// ---------------------------------------------------------------------------
18 18
diff --git a/server/initializers/migrations/0190-video-comment-unique-url.ts b/server/initializers/migrations/0190-video-comment-unique-url.ts
new file mode 100644
index 000000000..b196c9352
--- /dev/null
+++ b/server/initializers/migrations/0190-video-comment-unique-url.ts
@@ -0,0 +1,23 @@
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 {
9 const query = 'DELETE FROM "videoComment" s1 ' +
10 'USING (SELECT MIN(id) as id, url FROM "videoComment" GROUP BY "url" HAVING COUNT(*) > 1) s2 ' +
11 'WHERE s1."url" = s2."url" AND s1.id <> s2.id'
12 await utils.sequelize.query(query)
13 }
14}
15
16function down (options) {
17 throw new Error('Not implemented.')
18}
19
20export {
21 up,
22 down
23}