Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4d2ab7d757fe8cc68b5158492c38cc6c65e0151e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class AddSectionNameIdIndexOnCiBuildTraceSections < ActiveRecord::Migration[4.2]
  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