]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/initializers/migrations/0240-drop-old-indexes.ts
Move config in its own file
[github/Chocobozzz/PeerTube.git] / server / initializers / migrations / 0240-drop-old-indexes.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<any> {
8
9 const indexNames = [
10 'accounts_application_id',
11 'accounts_user_id',
12 'accounts_name',
13
14 'account_video_rates_video_id_account_id',
15 'account_video_rates_video_id_account_id_type',
16
17 'account_follows_account_id_target_account_id',
18 'account_follow_account_id_target_account_id',
19 'account_follow_account_id',
20 'account_follow_target_account_id',
21 'account_follows_account_id',
22 'account_follows_target_account_id',
23
24 'o_auth_clients_client_id',
25 'o_auth_clients_client_id_client_secret',
26
27 'o_auth_tokens_access_token',
28 'o_auth_tokens_refresh_token',
29 'o_auth_tokens_o_auth_client_id',
30 'o_auth_tokens_user_id',
31
32 'pods_host',
33 'servers_host',
34
35 'tags_name',
36
37 'users_email',
38 'users_username',
39
40 'videos_channel_id',
41 'videos_created_at',
42 'videos_duration',
43 'videos_likes',
44 'videos_name',
45 'videos_uuid',
46 'videos_views',
47
48 'video_abuses_reporter_account_id',
49 'video_abuses_video_id',
50
51 'blacklisted_videos_video_id',
52
53 'video_channels_account_id',
54
55 'video_files_info_hash',
56 'video_files_video_id',
57
58 'video_shares_account_id',
59 'video_shares_video_id',
60
61 'video_tags_tag_id',
62 'video_tags_video_id'
63 ]
64
65 for (const indexName of indexNames) {
66 await utils.sequelize.query('DROP INDEX IF EXISTS "' + indexName + '";')
67 }
68
69 await utils.sequelize.query('ALTER TABLE "account" DROP CONSTRAINT IF EXISTS "actorId_foreign_idx";')
70 await utils.sequelize.query('ALTER TABLE "videoChannel" DROP CONSTRAINT IF EXISTS "actorId_foreign_idx";')
71 await utils.sequelize.query('ALTER TABLE "videoShare" DROP CONSTRAINT IF EXISTS "VideoShares_videoId_fkey";')
72
73 await utils.sequelize.query('DROP TABLE IF EXISTS "videoChannelShare";')
74 }
75
76 function down (options) {
77 throw new Error('Not implemented.')
78 }
79
80 export { up, down }