From: Chocobozzz Date: Fri, 27 Jul 2018 15:22:20 +0000 (+0200) Subject: Delete old indexes X-Git-Tag: v1.0.0-beta.10.pre.3~21 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;ds=sidebyside;h=7a93e28110b89bea658e4919038505c4b44de2b6;p=github%2FChocobozzz%2FPeerTube.git Delete old indexes --- diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 85c5335ad..3aa979668 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -14,7 +14,7 @@ let config: IConfig = require('config') // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 235 +const LAST_MIGRATION_VERSION = 240 // --------------------------------------------------------------------------- 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 @@ +import * as Sequelize from 'sequelize' +import { createClient } from 'redis' +import { CONFIG } from '../constants' +import { JobQueue } from '../../lib/job-queue' +import { initDatabaseModels } from '../database' + +async function up (utils: { + transaction: Sequelize.Transaction + queryInterface: Sequelize.QueryInterface + sequelize: Sequelize.Sequelize +}): Promise { + + const indexNames = [ + 'accounts_application_id', + 'accounts_user_id', + 'accounts_name', + + 'account_video_rates_video_id_account_id', + 'account_video_rates_video_id_account_id_type', + + 'account_follows_account_id_target_account_id', + 'account_follow_account_id_target_account_id', + 'account_follow_account_id', + 'account_follow_target_account_id', + 'account_follows_account_id', + 'account_follows_target_account_id', + + 'o_auth_clients_client_id', + 'o_auth_clients_client_id_client_secret', + + 'o_auth_tokens_access_token', + 'o_auth_tokens_refresh_token', + 'o_auth_tokens_o_auth_client_id', + 'o_auth_tokens_user_id', + + 'pods_host', + 'servers_host', + + 'tags_name', + + 'users_email', + 'users_username', + + 'videos_channel_id', + 'videos_created_at', + 'videos_duration', + 'videos_likes', + 'videos_name', + 'videos_uuid', + 'videos_views', + + 'video_abuses_reporter_account_id', + 'video_abuses_video_id', + + 'blacklisted_videos_video_id', + + 'video_channels_account_id', + + 'video_files_info_hash', + 'video_files_video_id', + + 'video_shares_account_id', + 'video_shares_video_id', + + 'video_tags_tag_id', + 'video_tags_video_id' + ] + + for (const indexName of indexNames) { + await utils.sequelize.query('DROP INDEX IF EXISTS "' + indexName + '";') + } + + await utils.sequelize.query('ALTER TABLE "account" DROP CONSTRAINT IF EXISTS "actorId_foreign_idx";') + await utils.sequelize.query('ALTER TABLE "videoChannel" DROP CONSTRAINT IF EXISTS "actorId_foreign_idx";') + await utils.sequelize.query('ALTER TABLE "videoShare" DROP CONSTRAINT IF EXISTS "VideoShares_videoId_fkey";') + + await utils.sequelize.query('DROP TABLE IF EXISTS "videoChannelShare";') +} + +function down (options) { + throw new Error('Not implemented.') +} + +export { up, down }