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

20230823161514_remove_namespaces_routes_namespace_id_fk.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a640ac686edb92e958839d06fcdd2706b49ddb13 (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 RemoveNamespacesRoutesNamespaceIdFk < Gitlab::Database::Migration[2.1]
  disable_ddl_transaction!

  FOREIGN_KEY_NAME = "fk_bb2e5b8968"

  def up
    return unless foreign_key_exists?(:routes, :namespaces, name: FOREIGN_KEY_NAME)

    with_lock_retries do
      remove_foreign_key_if_exists(:routes, :namespaces,
        name: FOREIGN_KEY_NAME, reverse_lock_order: true)
    end
  end

  def down
    add_concurrent_foreign_key(:routes, :namespaces,
      name: FOREIGN_KEY_NAME, column: :namespace_id,
      target_column: :id, on_delete: :cascade)
  end
end