From 57e4e1c1a95c3a81a967f54ecc2a510d8b0e129c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 18 Mar 2022 11:17:35 +0100 Subject: Don't store remote rates of remote videos In the future we'll stop to expose all available rates to improve users privacy --- .../migrations/0695-remove-remote-rates.ts | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 server/initializers/migrations/0695-remove-remote-rates.ts (limited to 'server/initializers/migrations/0695-remove-remote-rates.ts') 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 @@ +import * as Sequelize from 'sequelize' + +async function up (utils: { + transaction: Sequelize.Transaction + queryInterface: Sequelize.QueryInterface + sequelize: Sequelize.Sequelize + db: any +}): Promise { + const query = 'DELETE FROM "accountVideoRate" ' + + 'WHERE "accountVideoRate".id IN (' + + 'SELECT "accountVideoRate".id FROM "accountVideoRate" ' + + 'INNER JOIN account ON account.id = "accountVideoRate"."accountId" ' + + 'INNER JOIN actor ON actor.id = account."actorId" ' + + 'INNER JOIN video ON video.id = "accountVideoRate"."videoId" ' + + 'WHERE actor."serverId" IS NOT NULL AND video.remote IS TRUE' + + ')' + + await utils.sequelize.query(query, { type: Sequelize.QueryTypes.BULKDELETE, transaction: utils.transaction }) +} + +function down () { + throw new Error('Not implemented.') +} + +export { + up, + down +} -- cgit v1.2.3