summaryrefslogtreecommitdiff
path: root/db/migrate/20160919145149_add_group_id_to_labels.rb
blob: 828b6afddb1b4b44d167a4ffebf24387e01cf152 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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_index :labels, :group_id if index_exists? :labels, :group_id
    remove_foreign_key :labels, :namespaces, column: :group_id
    remove_column :labels, :group_id
  end
end