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

20190703171555_add_sourcing_epic_dates_fks.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4995a3cd03f332f651fb22c83a831f5463ff48c6 (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
# frozen_string_literal: true

class AddSourcingEpicDatesFks < ActiveRecord::Migration[5.1]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    add_concurrent_index :epics, :start_date_sourcing_epic_id, where: 'start_date_sourcing_epic_id is not null'
    add_concurrent_index :epics, :due_date_sourcing_epic_id, where: 'due_date_sourcing_epic_id is not null'

    add_concurrent_foreign_key :epics, :epics, column: :start_date_sourcing_epic_id, on_delete: :nullify
    add_concurrent_foreign_key :epics, :epics, column: :due_date_sourcing_epic_id, on_delete: :nullify
  end

  def down
    remove_foreign_key_if_exists :epics, column: :start_date_sourcing_epic_id
    remove_foreign_key_if_exists :epics, column: :due_date_sourcing_epic_id

    remove_concurrent_index :epics, :start_date_sourcing_epic_id
    remove_concurrent_index :epics, :due_date_sourcing_epic_id
  end
end