summaryrefslogtreecommitdiff
path: root/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb
blob: 55bf40ba24db67b1cd7b655b8bc898e66186eeda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class AddForeignKeyPipelineSchedulesAndPipelines < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    on_delete =
      if Gitlab::Database.mysql?
        :nullify
      else
        'SET NULL'
      end

    add_concurrent_foreign_key  :ci_pipelines, :ci_pipeline_schedules,
      column: :pipeline_schedule_id, on_delete: on_delete
  end

  def down
    remove_foreign_key :ci_pipelines, column: :pipeline_schedule_id
  end
end