diff options
Diffstat (limited to 'server/initializers/migrations')
-rw-r--r-- | server/initializers/migrations/0235-delete-some-video-indexes.ts | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/server/initializers/migrations/0235-delete-some-video-indexes.ts b/server/initializers/migrations/0235-delete-some-video-indexes.ts new file mode 100644 index 000000000..e362f240c --- /dev/null +++ b/server/initializers/migrations/0235-delete-some-video-indexes.ts | |||
@@ -0,0 +1,41 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { createClient } from 'redis' | ||
3 | import { CONFIG } from '../constants' | ||
4 | import { JobQueue } from '../../lib/job-queue' | ||
5 | import { initDatabaseModels } from '../database' | ||
6 | |||
7 | async function up (utils: { | ||
8 | transaction: Sequelize.Transaction | ||
9 | queryInterface: Sequelize.QueryInterface | ||
10 | sequelize: Sequelize.Sequelize | ||
11 | }): Promise<any> { | ||
12 | await utils.sequelize.query('DROP INDEX IF EXISTS video_id_privacy_state_wait_transcoding;') | ||
13 | await utils.sequelize.query('DROP INDEX IF EXISTS video_name;') | ||
14 | |||
15 | for (let i = 0; i < 5; i++) { | ||
16 | const query = 'DELETE FROM "videoFile" WHERE id IN ' + | ||
17 | '(SELECT id FROM (SELECT MIN(id) AS id, "videoId", "resolution", "fps" ' + | ||
18 | 'FROM "videoFile" GROUP BY "videoId", "resolution", "fps" HAVING COUNT(*) > 1) t)' | ||
19 | await utils.sequelize.query(query) | ||
20 | } | ||
21 | |||
22 | for (let i = 0; i < 5; i++) { | ||
23 | const query = 'DELETE FROM "actor" WHERE id IN ' + | ||
24 | '(SELECT id FROM (SELECT MIN(id) AS id, "uuid" ' + | ||
25 | 'FROM "actor" GROUP BY "uuid" HAVING COUNT(*) > 1) t)' | ||
26 | await utils.sequelize.query(query) | ||
27 | } | ||
28 | |||
29 | for (let i = 0; i < 5; i++) { | ||
30 | const query = 'DELETE FROM "account" WHERE id IN ' + | ||
31 | '(SELECT id FROM (SELECT MIN(id) AS id, "actorId" ' + | ||
32 | 'FROM "account" GROUP BY "actorId" HAVING COUNT(*) > 1) t)' | ||
33 | await utils.sequelize.query(query) | ||
34 | } | ||
35 | } | ||
36 | |||
37 | function down (options) { | ||
38 | throw new Error('Not implemented.') | ||
39 | } | ||
40 | |||
41 | export { up, down } | ||