BigW Consortium Gitlab

20160919145149_add_group_id_to_labels.rb 593 Bytes
Newer Older
1
# rubocop:disable RemoveIndex
2 3 4 5 6 7 8
class AddGroupIdToLabels < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

9
  def up
10
    add_column :labels, :group_id, :integer
11
    add_foreign_key :labels, :namespaces, column: :group_id, on_delete: :cascade # rubocop: disable Migration/AddConcurrentForeignKey
12 13
    add_concurrent_index :labels, :group_id
  end
14 15

  def down
16
    remove_foreign_key :labels, column: :group_id
17 18 19
    remove_index :labels, :group_id if index_exists? :labels, :group_id
    remove_column :labels, :group_id
  end
20
end