Move to eslint
[oweals/peertube.git] / server / initializers / migrations / 0190-video-comment-unique-url.ts
1 import * as Sequelize from 'sequelize'
2
3 async 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
16 function down (options) {
17   throw new Error('Not implemented.')
18 }
19
20 export {
21   up,
22   down
23 }