diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-10-05 13:12:08 +0200 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-10-05 13:12:08 +0200 |
commit | 5daa8fbc29ee2fc309602d24167a401563bc3b2c (patch) | |
tree | b99d1b6c54435e2fe1c2565c87ab9a41c36a5cd2 /db/migrate/20170928100231_add_composite_index_on_merge_requests_merge_commit_sha.rb | |
parent | e0fdcd19ec1973963452dde4384e071286f044b1 (diff) | |
parent | de01353b166018a43ea92b38054b1267c3ba5cea (diff) | |
download | gitlab-ce-5daa8fbc29ee2fc309602d24167a401563bc3b2c.tar.gz |
Add changelog
Diffstat (limited to 'db/migrate/20170928100231_add_composite_index_on_merge_requests_merge_commit_sha.rb')
-rw-r--r-- | db/migrate/20170928100231_add_composite_index_on_merge_requests_merge_commit_sha.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/db/migrate/20170928100231_add_composite_index_on_merge_requests_merge_commit_sha.rb b/db/migrate/20170928100231_add_composite_index_on_merge_requests_merge_commit_sha.rb new file mode 100644 index 00000000000..9f02daf04c1 --- /dev/null +++ b/db/migrate/20170928100231_add_composite_index_on_merge_requests_merge_commit_sha.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 AddCompositeIndexOnMergeRequestsMergeCommitSha < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + # The default index name is too long for PostgreSQL and would thus be + # truncated. + INDEX_NAME = 'index_merge_requests_on_tp_id_and_merge_commit_sha_and_id' + + COLUMNS = [:target_project_id, :merge_commit_sha, :id] + + disable_ddl_transaction! + + def up + return if index_is_present? + + add_concurrent_index(:merge_requests, COLUMNS, name: INDEX_NAME) + end + + def down + return unless index_is_present? + + remove_concurrent_index(:merge_requests, COLUMNS, name: INDEX_NAME) + end + + def index_is_present? + index_exists?(:merge_requests, COLUMNS, name: INDEX_NAME) + end +end |