BigW Consortium Gitlab

Commit 08fbbaa8 by Yorick Peterse Committed by Robert Speicher

Merge branch 'sh-make-add-index-idempotent' into 'master'

Fix index name to Rails default to ensure idempotency See merge request gitlab-org/gitlab-ce!17654
parent f1b8563a
...@@ -3,20 +3,21 @@ class AddSectionNameIdIndexOnCiBuildTraceSections < ActiveRecord::Migration ...@@ -3,20 +3,21 @@ class AddSectionNameIdIndexOnCiBuildTraceSections < ActiveRecord::Migration
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
DOWNTIME = false DOWNTIME = false
INDEX_NAME = 'index_ci_build_trace_sections_on_section_name_id'
disable_ddl_transaction! disable_ddl_transaction!
def up def up
# MySQL may already have this as a foreign key # MySQL may already have this as a foreign key
unless index_exists?(:ci_build_trace_sections, :section_name_id) unless index_exists?(:ci_build_trace_sections, :section_name_id, name: INDEX_NAME)
add_concurrent_index :ci_build_trace_sections, :section_name_id add_concurrent_index :ci_build_trace_sections, :section_name_id, name: INDEX_NAME
end end
end end
def down def down
# We cannot remove index for MySQL because it's needed for foreign key # We cannot remove index for MySQL because it's needed for foreign key
if Gitlab::Database.postgresql? if Gitlab::Database.postgresql?
remove_concurrent_index :ci_build_trace_sections, :section_name_id remove_concurrent_index :ci_build_trace_sections, :section_name_id, name: INDEX_NAME
end end
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment