summaryrefslogtreecommitdiff
path: root/db/post_migrate/20220112015940_remove_projects_ci_running_builds_fk.rb
blob: 79d864e2c2af2ccf06a4bf5c37cc9fd3b59528a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

class RemoveProjectsCiRunningBuildsFk < Gitlab::Database::Migration[1.0]
  disable_ddl_transaction!

  def up
    with_lock_retries do
      execute('LOCK projects, ci_running_builds IN ACCESS EXCLUSIVE MODE')

      remove_foreign_key_if_exists(:ci_running_builds, :projects, name: "fk_rails_dc1d0801e8")
    end
  end

  def down
    add_concurrent_foreign_key(:ci_running_builds, :projects, name: "fk_rails_dc1d0801e8", column: :project_id, target_column: :id, on_delete: "cascade")
  end
end