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

20230925062516_add_foreign_key_for_ci_stages_pipeline_id_bigint.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ba75cf4037fca6811ed6f236fef35b533e77558f (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 AddForeignKeyForCiStagesPipelineIdBigint < Gitlab::Database::Migration[2.1]
  TABLE_NAME = :ci_stages
  REFERENCING_TABLE_NAME = :ci_pipelines
  COLUMN_NAME = :pipeline_id_convert_to_bigint

  disable_ddl_transaction!

  def up
    add_concurrent_foreign_key(
      TABLE_NAME, REFERENCING_TABLE_NAME,
      column: COLUMN_NAME, on_delete: :cascade, 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