diff options
Diffstat (limited to 'db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb')
-rw-r--r-- | db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb b/db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb new file mode 100644 index 00000000000..b616cc2fd30 --- /dev/null +++ b/db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb @@ -0,0 +1,23 @@ +class AddSectionNameIdIndexOnCiBuildTraceSections < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + INDEX_NAME = 'index_ci_build_trace_sections_on_section_name_id' + + disable_ddl_transaction! + + def up + # MySQL may already have this as a foreign key + 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 + end + end + + def down + # We cannot remove index for MySQL because it's needed for foreign key + if Gitlab::Database.postgresql? + remove_concurrent_index :ci_build_trace_sections, :section_name_id, name: INDEX_NAME + end + end +end |