20170312114529_add_auto_canceled_by_id_foreign_key_to_pipeline.rb 494 Bytes
Newer Older
1
class AddAutoCanceledByIdForeignKeyToPipeline < ActiveRecord::Migration[4.2]
Rydkin Maxim's avatar
Rydkin Maxim committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  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_pipelines, column: :auto_canceled_by_id, on_delete: on_delete
  end

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