gitlab-org--gitlab-foss/db/migrate/20160919145149_add_group_id_to_labels.rb
2017-03-14 02:12:55 +08:00

19 lines
563 B
Ruby

class AddGroupIdToLabels < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_column :labels, :group_id, :integer
add_foreign_key :labels, :namespaces, column: :group_id, on_delete: :cascade # rubocop: disable Migration/AddConcurrentForeignKey
add_concurrent_index :labels, :group_id
end
def down
remove_foreign_key :labels, column: :group_id
remove_index :labels, :group_id if index_exists? :labels, :group_id
remove_column :labels, :group_id
end
end