diff options
author | Valery Sizov <valery@gitlab.com> | 2016-11-28 16:44:24 +0200 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2016-11-29 14:40:48 +0200 |
commit | a48ef15620bd479bcbe1c47e60eaa4c84dbd0f8f (patch) | |
tree | eb686e1cc995e80bc60b205ee952d1b46958f951 /db/migrate/20161128142110_remove_unnecessary_indexes.rb | |
parent | 35e6c2baca12d3aaf6bf2ee69c43d0874341c0ce (diff) | |
download | gitlab-ce-a48ef15620bd479bcbe1c47e60eaa4c84dbd0f8f.tar.gz |
Remove unnecessary database indexes
Diffstat (limited to 'db/migrate/20161128142110_remove_unnecessary_indexes.rb')
-rw-r--r-- | db/migrate/20161128142110_remove_unnecessary_indexes.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/db/migrate/20161128142110_remove_unnecessary_indexes.rb b/db/migrate/20161128142110_remove_unnecessary_indexes.rb new file mode 100644 index 00000000000..9deab19782e --- /dev/null +++ b/db/migrate/20161128142110_remove_unnecessary_indexes.rb @@ -0,0 +1,33 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class RemoveUnnecessaryIndexes < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + disable_ddl_transaction! + + DOWNTIME = false + + def up + remove_index :labels, column: :group_id if index_exists?(:labels, :group_id) + remove_index :award_emoji, column: :user_id if index_exists?(:award_emoji, :user_id) + remove_index :ci_builds, column: :commit_id if index_exists?(:ci_builds, :commit_id) + remove_index :deployments, column: :project_id if index_exists?(:deployments, :project_id) + remove_index :deployments, column: ["project_id", "environment_id"] if index_exists?(:deployments, ["project_id", "environment_id"]) + remove_index :lists, column: :board_id if index_exists?(:lists, :board_id) + remove_index :milestones, column: :project_id if index_exists?(:milestones, :project_id) + remove_index :notes, column: :project_id if index_exists?(:notes, :project_id) + remove_index :users_star_projects, column: :user_id if index_exists?(:users_star_projects, :user_id) + end + + def down + add_concurrent_index :labels, :group_id + add_concurrent_index :award_emoji, :user_id + add_concurrent_index :ci_builds, :commit_id + add_concurrent_index :deployments, :project_id + add_concurrent_index :deployments, ["project_id", "environment_id"] + add_concurrent_index :lists, :board_id + add_concurrent_index :milestones, :project_id + add_concurrent_index :notes, :project_id + add_concurrent_index :users_star_projects, :user_id + end +end |