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

20230406150454_add_fks_to_agent_user_access_authorizations.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 62f0062010816e93706d6202b1a03b22c9c6de3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

class AddFksToAgentUserAccessAuthorizations < Gitlab::Database::Migration[2.1]
  disable_ddl_transaction!

  def up
    add_concurrent_foreign_key :agent_user_access_project_authorizations, :projects,
      column: :project_id, on_delete: :cascade
    add_concurrent_foreign_key :agent_user_access_project_authorizations, :cluster_agents,
      column: :agent_id, on_delete: :cascade
    add_concurrent_foreign_key :agent_user_access_group_authorizations, :namespaces,
      column: :group_id, on_delete: :cascade
    add_concurrent_foreign_key :agent_user_access_group_authorizations, :cluster_agents,
      column: :agent_id, on_delete: :cascade
  end

  def down
    with_lock_retries do
      remove_foreign_key_if_exists :agent_user_access_project_authorizations, column: :project_id
    end

    with_lock_retries do
      remove_foreign_key_if_exists :agent_user_access_project_authorizations, column: :agent_id
    end

    with_lock_retries do
      remove_foreign_key_if_exists :agent_user_access_group_authorizations, column: :group_id
    end

    with_lock_retries do
      remove_foreign_key_if_exists :agent_user_access_group_authorizations, column: :agent_id
    end
  end
end