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

20220726182310_add_user_fk_to_vulnerability_state_transitions.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ad0bf6141b216a7066a41fdcc326d26bf0c0ed73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

class AddUserFkToVulnerabilityStateTransitions < Gitlab::Database::Migration[2.0]
  disable_ddl_transaction!

  INDEX_NAME = 'index_vulnerability_state_transitions_on_author_id'

  def up
    add_concurrent_index :vulnerability_state_transitions, :author_id, name: INDEX_NAME
    add_concurrent_foreign_key :vulnerability_state_transitions, :users, column: :author_id, on_delete: :nullify
  end

  def down
    with_lock_retries do
      remove_foreign_key :vulnerability_state_transitions, column: :author_id
    end

    remove_concurrent_index_by_name :vulnerability_state_transitions, INDEX_NAME
  end
end