2019-09-03 17:29:55 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class AddGroupColumnToEvents < ActiveRecord::Migration[5.2]
|
2019-09-10 07:52:48 -04:00
|
|
|
include Gitlab::Database::MigrationHelpers
|
|
|
|
|
2019-09-03 17:29:55 -04:00
|
|
|
DOWNTIME = false
|
|
|
|
|
2019-09-10 07:52:48 -04:00
|
|
|
disable_ddl_transaction!
|
|
|
|
|
|
|
|
def up
|
|
|
|
add_column(:events, :group_id, :bigint) unless column_exists?(:events, :group_id)
|
|
|
|
add_concurrent_index(:events, :group_id)
|
|
|
|
add_concurrent_foreign_key(:events, :namespaces, column: :group_id, on_delete: :cascade)
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
remove_column(:events, :group_id) if column_exists?(:events, :group_id)
|
2019-09-03 17:29:55 -04:00
|
|
|
end
|
|
|
|
end
|