aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations/0240-drop-old-indexes.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-07-27 17:22:20 +0200
committerChocobozzz <me@florianbigard.com>2018-07-27 17:22:20 +0200
commit7a93e28110b89bea658e4919038505c4b44de2b6 (patch)
tree4267ac4660a7c9a13fb271740d59b0c331c8ad7f /server/initializers/migrations/0240-drop-old-indexes.ts
parent8d194d9a5c2b0acbf89f5832a8dd428bc722881b (diff)
downloadPeerTube-7a93e28110b89bea658e4919038505c4b44de2b6.tar.gz
PeerTube-7a93e28110b89bea658e4919038505c4b44de2b6.tar.zst
PeerTube-7a93e28110b89bea658e4919038505c4b44de2b6.zip
Delete old indexes
Diffstat (limited to 'server/initializers/migrations/0240-drop-old-indexes.ts')
-rw-r--r--server/initializers/migrations/0240-drop-old-indexes.ts84
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 @@
1import * as Sequelize from 'sequelize'
2import { createClient } from 'redis'
3import { CONFIG } from '../constants'
4import { JobQueue } from '../../lib/job-queue'
5import { initDatabaseModels } from '../database'
6
7async 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
80function down (options) {
81 throw new Error('Not implemented.')
82}
83
84export { up, down }