2018-03-17 18:26:18 +05:30
|
|
|
class AddSectionNameIdIndexOnCiBuildTraceSections < ActiveRecord::Migration
|
|
|
|
include Gitlab::Database::MigrationHelpers
|
|
|
|
|
|
|
|
# Set this constant to true if this migration requires downtime.
|
|
|
|
DOWNTIME = false
|
2018-03-27 19:54:05 +05:30
|
|
|
INDEX_NAME = 'index_ci_build_trace_sections_on_section_name_id'
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
disable_ddl_transaction!
|
|
|
|
|
|
|
|
def up
|
|
|
|
# MySQL may already have this as a foreign key
|
2018-03-27 19:54:05 +05:30
|
|
|
unless index_exists?(:ci_build_trace_sections, :section_name_id, name: INDEX_NAME)
|
|
|
|
add_concurrent_index :ci_build_trace_sections, :section_name_id, name: INDEX_NAME
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
# We cannot remove index for MySQL because it's needed for foreign key
|
|
|
|
if Gitlab::Database.postgresql?
|
2018-03-27 19:54:05 +05:30
|
|
|
remove_concurrent_index :ci_build_trace_sections, :section_name_id, name: INDEX_NAME
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|