summaryrefslogtreecommitdiff
path: root/db/migrate/20210208144134_add_index_group_id_to_ci_daily_build_group_report_results.rb
blob: 422d8174043506bc4a24104093855d46eed8e05b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

class AddIndexGroupIdToCiDailyBuildGroupReportResults < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false
  INDEX_NAME = 'index_ci_daily_build_group_report_results_on_group_id'

  disable_ddl_transaction!

  def up
    add_concurrent_index(:ci_daily_build_group_report_results, :group_id, name: INDEX_NAME)
    add_concurrent_foreign_key(:ci_daily_build_group_report_results, :namespaces, column: :group_id)
  end

  def down
    remove_foreign_key_if_exists(:ci_daily_build_group_report_results, column: :group_id)
    remove_concurrent_index_by_name(:ci_daily_build_group_report_results, INDEX_NAME)
  end
end