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

20200527135313_add_requirements_build_reference.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3385243fbdd382a169fccb3633c2c2cd88c9fb9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

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

  DOWNTIME = false
  INDEX_NAME = 'index_requirements_management_test_reports_on_build_id'

  def up
    add_column :requirements_management_test_reports, :build_id, :bigint
    add_index :requirements_management_test_reports, :build_id, name: INDEX_NAME # rubocop:disable Migration/AddIndex

    with_lock_retries do
      add_foreign_key :requirements_management_test_reports, :ci_builds, column: :build_id, on_delete: :nullify # rubocop:disable Migration/AddConcurrentForeignKey
    end
  end

  def down
    with_lock_retries do
      remove_column :requirements_management_test_reports, :build_id
    end
  end
end