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

20230109145018_remove_namespaces_application_settings_custom_project_templates_group_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: cfc915f57b45601465488510323a9135dd0c6569 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

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

  def up
    return unless foreign_key_exists?(:application_settings, :namespaces, name: "fk_rails_b53e481273")

    with_lock_retries do
      execute('LOCK namespaces, application_settings IN ACCESS EXCLUSIVE MODE') if transaction_open?

      remove_foreign_key_if_exists(:application_settings, :namespaces, name: "fk_rails_b53e481273")
    end
  end

  def down
    add_concurrent_foreign_key(:application_settings, :namespaces,
      name: "fk_rails_b53e481273", column: :custom_project_templates_group_id,
      target_column: :id, on_delete: :nullify)
  end
end