From e31e70d461a25a9772dca71568effc32732d4bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Thu, 15 Nov 2018 13:01:10 +0100 Subject: [PATCH] Remove indexes for FK --- ...46_add_missing_indexes_for_foreign_keys.rb | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/db/migrate/20181030154446_add_missing_indexes_for_foreign_keys.rb b/db/migrate/20181030154446_add_missing_indexes_for_foreign_keys.rb index ffd37f54965..8a639e3275b 100644 --- a/db/migrate/20181030154446_add_missing_indexes_for_foreign_keys.rb +++ b/db/migrate/20181030154446_add_missing_indexes_for_foreign_keys.rb @@ -33,6 +33,31 @@ class AddMissingIndexesForForeignKeys < ActiveRecord::Migration end def down - # no-op + # MySQL requires index for FK, + # thus removal of indexes does fail + return if Gitlab::Database.mysql? + + remove_concurrent_index(:application_settings, :usage_stats_set_by_user_id) + remove_concurrent_index(:ci_pipeline_schedules, :owner_id) + remove_concurrent_index(:ci_trigger_requests, :trigger_id) + remove_concurrent_index(:ci_triggers, :owner_id) + remove_concurrent_index(:clusters_applications_helm, :cluster_id, unique: true) + remove_concurrent_index(:clusters_applications_ingress, :cluster_id, unique: true) + remove_concurrent_index(:clusters_applications_jupyter, :cluster_id, unique: true) + remove_concurrent_index(:clusters_applications_jupyter, :oauth_application_id) + remove_concurrent_index(:clusters_applications_prometheus, :cluster_id, unique: true) + remove_concurrent_index(:fork_network_members, :forked_from_project_id) + remove_concurrent_index(:internal_ids, :namespace_id) + remove_concurrent_index(:internal_ids, :project_id) + remove_concurrent_index(:issues, :closed_by_id) + remove_concurrent_index(:label_priorities, :label_id) + remove_concurrent_index(:merge_request_metrics, :merged_by_id) + remove_concurrent_index(:merge_request_metrics, :latest_closed_by_id) + remove_concurrent_index(:oauth_openid_requests, :access_grant_id) + remove_concurrent_index(:project_deploy_tokens, :deploy_token_id) + remove_concurrent_index(:protected_tag_create_access_levels, :group_id) + remove_concurrent_index(:subscriptions, :project_id) + remove_concurrent_index(:user_statuses, :user_id) + remove_concurrent_index(:users, :accepted_term_id) end end