2016-09-19 15:04:38 +00:00
|
|
|
class AddGroupIdToLabels < ActiveRecord::Migration
|
|
|
|
include Gitlab::Database::MigrationHelpers
|
|
|
|
|
|
|
|
DOWNTIME = false
|
|
|
|
|
|
|
|
disable_ddl_transaction!
|
|
|
|
|
2017-03-07 16:08:53 +00:00
|
|
|
def up
|
2016-09-19 15:04:38 +00:00
|
|
|
add_column :labels, :group_id, :integer
|
2017-02-09 15:52:43 +00:00
|
|
|
add_foreign_key :labels, :namespaces, column: :group_id, on_delete: :cascade # rubocop: disable Migration/AddConcurrentForeignKey
|
2016-09-19 15:04:38 +00:00
|
|
|
add_concurrent_index :labels, :group_id
|
|
|
|
end
|
2017-03-07 16:08:53 +00:00
|
|
|
|
|
|
|
def down
|
2017-03-13 12:36:17 +00:00
|
|
|
remove_foreign_key :labels, column: :group_id
|
2017-03-07 16:08:53 +00:00
|
|
|
remove_index :labels, :group_id if index_exists? :labels, :group_id
|
|
|
|
remove_column :labels, :group_id
|
|
|
|
end
|
2016-09-19 15:04:38 +00:00
|
|
|
end
|