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

20201119162801_change_services_inherit_from_id_foreign_key.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a7f12fcf7268072a994febe906a9be7c6f6c1f08 (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 ChangeServicesInheritFromIdForeignKey < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    add_concurrent_foreign_key :services, :services, column: :inherit_from_id, on_delete: :cascade, name: 'fk_services_inherit_from_id'
    remove_foreign_key_if_exists :services, name: 'fk_868a8e7ad6'
  end

  def down
    remove_foreign_key_if_exists :services, name: 'fk_services_inherit_from_id'
    add_concurrent_foreign_key :services, :services, column: :inherit_from_id, on_delete: :nullify, name: 'fk_868a8e7ad6'
  end
end