aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-29 11:58:07 +0100
committerChocobozzz <me@florianbigard.com>2018-01-29 11:58:07 +0100
commit4805cff179cbf518abb4c1b494b477c71f84b989 (patch)
treee5b510f874418a540f853e0f6e878fc2b1ee8035 /server/initializers/migrations
parent93bd24a97dd6115d66833b59f6a82c248c6a5195 (diff)
downloadPeerTube-4805cff179cbf518abb4c1b494b477c71f84b989.tar.gz
PeerTube-4805cff179cbf518abb4c1b494b477c71f84b989.tar.zst
PeerTube-4805cff179cbf518abb4c1b494b477c71f84b989.zip
Fix migrations
Diffstat (limited to 'server/initializers/migrations')
-rw-r--r--server/initializers/migrations/0190-video-comment-unique-url.ts23
1 files changed, 23 insertions, 0 deletions
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}