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

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

  CONSTRAINT_NAME = 'fk_fdc0137e4a'

  def up
    with_lock_retries do
      remove_foreign_key_if_exists(:ci_pending_builds, :namespaces, name: CONSTRAINT_NAME)
    end
  end

  def down
    add_concurrent_foreign_key :ci_pending_builds, :namespaces, column: :namespace_id, on_delete: :cascade, name: CONSTRAINT_NAME
  end
end