20170406115029_add_auto_canceled_by_id_foreign_key_to_ci_builds.rb 488 Bytes
Newer Older
1
class AddAutoCanceledByIdForeignKeyToCiBuilds < ActiveRecord::Migration[4.2]
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_builds, :ci_pipelines, column: :auto_canceled_by_id, on_delete: on_delete
  end

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