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