diff options
Diffstat (limited to 'server/initializers/migrations/0695-remove-remote-rates.ts')
-rw-r--r-- | server/initializers/migrations/0695-remove-remote-rates.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/server/initializers/migrations/0695-remove-remote-rates.ts b/server/initializers/migrations/0695-remove-remote-rates.ts new file mode 100644 index 000000000..f5c394bae --- /dev/null +++ b/server/initializers/migrations/0695-remove-remote-rates.ts | |||
@@ -0,0 +1,28 @@ | |||
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 | db: any | ||
8 | }): Promise<void> { | ||
9 | const query = 'DELETE FROM "accountVideoRate" ' + | ||
10 | 'WHERE "accountVideoRate".id IN (' + | ||
11 | 'SELECT "accountVideoRate".id FROM "accountVideoRate" ' + | ||
12 | 'INNER JOIN account ON account.id = "accountVideoRate"."accountId" ' + | ||
13 | 'INNER JOIN actor ON actor.id = account."actorId" ' + | ||
14 | 'INNER JOIN video ON video.id = "accountVideoRate"."videoId" ' + | ||
15 | 'WHERE actor."serverId" IS NOT NULL AND video.remote IS TRUE' + | ||
16 | ')' | ||
17 | |||
18 | await utils.sequelize.query(query, { type: Sequelize.QueryTypes.BULKDELETE, transaction: utils.transaction }) | ||
19 | } | ||
20 | |||
21 | function down () { | ||
22 | throw new Error('Not implemented.') | ||
23 | } | ||
24 | |||
25 | export { | ||
26 | up, | ||
27 | down | ||
28 | } | ||