20170707184243_add_group_milestone_id_indexes.rb 499 Bytes
Newer Older
1
class AddGroupMilestoneIdIndexes < ActiveRecord::Migration[4.2]
Felipe Artur's avatar
Felipe Artur committed
2 3 4 5 6 7 8
  include Gitlab::Database::MigrationHelpers

  disable_ddl_transaction!

  DOWNTIME = false

  def up
9 10
    return if index_exists?(:milestones, :group_id)

Felipe Artur's avatar
Felipe Artur committed
11 12 13 14 15 16 17 18 19 20 21
    add_concurrent_foreign_key :milestones, :namespaces, column: :group_id, on_delete: :cascade

    add_concurrent_index :milestones, :group_id
  end

  def down
    remove_foreign_key :milestones, column: :group_id

    remove_concurrent_index :milestones, :group_id
  end
end