summaryrefslogtreecommitdiff
path: root/db/migrate/20200421233150_add_foreign_keys_for_alert_management_alerts.rb
blob: b16bdf9830c31ecfe5a6e3f079d9bb0e15290663 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

class AddForeignKeysForAlertManagementAlerts < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    add_concurrent_foreign_key :alert_management_alerts, :projects, column: :project_id, on_delete: :cascade
    add_concurrent_foreign_key :alert_management_alerts, :issues, column: :issue_id, on_delete: :nullify
  end

  def down
    remove_foreign_key_if_exists :alert_management_alerts, column: :project_id
    remove_foreign_key_if_exists :alert_management_alerts, column: :issue_id
  end
end