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

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

class AddForeignKeyForCiPipelinesPipelineIdBigint < Gitlab::Database::Migration[2.1]
  TABLE_NAME = :ci_pipelines
  REFERENCING_TABLE_NAME = :ci_pipelines
  COLUMN_NAME = :auto_canceled_by_id_convert_to_bigint

  disable_ddl_transaction!

  def up
    add_concurrent_foreign_key(
      TABLE_NAME, REFERENCING_TABLE_NAME,
      column: COLUMN_NAME, on_delete: :nullify, validate: false, reverse_lock_order: true
    )
  end

  def down
    with_lock_retries do
      remove_foreign_key_if_exists TABLE_NAME, column: COLUMN_NAME
    end
  end
end