gitlab-org--gitlab-foss/db/migrate/20190826100605_add_group_column_to_events.rb

20 lines
522 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class AddGroupColumnToEvents < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
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)
end
end