diff options
Diffstat (limited to 'server/initializers/migrations')
-rw-r--r-- | server/initializers/migrations/0240-drop-old-indexes.ts | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/server/initializers/migrations/0240-drop-old-indexes.ts b/server/initializers/migrations/0240-drop-old-indexes.ts new file mode 100644 index 000000000..ba961e3f9 --- /dev/null +++ b/server/initializers/migrations/0240-drop-old-indexes.ts | |||
@@ -0,0 +1,84 @@ | |||
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 | |||
13 | const indexNames = [ | ||
14 | 'accounts_application_id', | ||
15 | 'accounts_user_id', | ||
16 | 'accounts_name', | ||
17 | |||
18 | 'account_video_rates_video_id_account_id', | ||
19 | 'account_video_rates_video_id_account_id_type', | ||
20 | |||
21 | 'account_follows_account_id_target_account_id', | ||
22 | 'account_follow_account_id_target_account_id', | ||
23 | 'account_follow_account_id', | ||
24 | 'account_follow_target_account_id', | ||
25 | 'account_follows_account_id', | ||
26 | 'account_follows_target_account_id', | ||
27 | |||
28 | 'o_auth_clients_client_id', | ||
29 | 'o_auth_clients_client_id_client_secret', | ||
30 | |||
31 | 'o_auth_tokens_access_token', | ||
32 | 'o_auth_tokens_refresh_token', | ||
33 | 'o_auth_tokens_o_auth_client_id', | ||
34 | 'o_auth_tokens_user_id', | ||
35 | |||
36 | 'pods_host', | ||
37 | 'servers_host', | ||
38 | |||
39 | 'tags_name', | ||
40 | |||
41 | 'users_email', | ||
42 | 'users_username', | ||
43 | |||
44 | 'videos_channel_id', | ||
45 | 'videos_created_at', | ||
46 | 'videos_duration', | ||
47 | 'videos_likes', | ||
48 | 'videos_name', | ||
49 | 'videos_uuid', | ||
50 | 'videos_views', | ||
51 | |||
52 | 'video_abuses_reporter_account_id', | ||
53 | 'video_abuses_video_id', | ||
54 | |||
55 | 'blacklisted_videos_video_id', | ||
56 | |||
57 | 'video_channels_account_id', | ||
58 | |||
59 | 'video_files_info_hash', | ||
60 | 'video_files_video_id', | ||
61 | |||
62 | 'video_shares_account_id', | ||
63 | 'video_shares_video_id', | ||
64 | |||
65 | 'video_tags_tag_id', | ||
66 | 'video_tags_video_id' | ||
67 | ] | ||
68 | |||
69 | for (const indexName of indexNames) { | ||
70 | await utils.sequelize.query('DROP INDEX IF EXISTS "' + indexName + '";') | ||
71 | } | ||
72 | |||
73 | await utils.sequelize.query('ALTER TABLE "account" DROP CONSTRAINT IF EXISTS "actorId_foreign_idx";') | ||
74 | await utils.sequelize.query('ALTER TABLE "videoChannel" DROP CONSTRAINT IF EXISTS "actorId_foreign_idx";') | ||
75 | await utils.sequelize.query('ALTER TABLE "videoShare" DROP CONSTRAINT IF EXISTS "VideoShares_videoId_fkey";') | ||
76 | |||
77 | await utils.sequelize.query('DROP TABLE IF EXISTS "videoChannelShare";') | ||
78 | } | ||
79 | |||
80 | function down (options) { | ||
81 | throw new Error('Not implemented.') | ||
82 | } | ||
83 | |||
84 | export { up, down } | ||