gitlab-org--gitlab-foss/db/migrate/20160919145149_add_group_id_to_labels.rb

21 lines
598 B
Ruby
Raw Normal View History

# rubocop:disable RemoveIndex
class AddGroupIdToLabels < ActiveRecord::Migration[4.2]
2016-09-19 11:04:38 -04:00
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
2016-09-19 11:04:38 -04:00
add_column :labels, :group_id, :integer
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
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
2016-09-19 11:04:38 -04:00
end