summaryrefslogtreecommitdiff
path: root/db/post_migrate/20220715054506_add_parent_link_unique_work_item_index.rb
blob: ed5b85b711c7906380ef2d56b65490af23b617f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

class AddParentLinkUniqueWorkItemIndex < Gitlab::Database::Migration[2.0]
  INDEX_NAME = 'index_work_item_parent_links_on_work_item_id'
  OLD_INDEX_NAME = 'index_parent_links_on_work_item_id_and_work_item_parent_id'

  disable_ddl_transaction!

  def up
    add_concurrent_index :work_item_parent_links, :work_item_id, unique: true, name: INDEX_NAME
    remove_concurrent_index_by_name :work_item_parent_links, OLD_INDEX_NAME
  end

  def down
    add_concurrent_index :work_item_parent_links, [:work_item_id, :work_item_parent_id],
      unique: true, name: OLD_INDEX_NAME
    remove_concurrent_index_by_name :work_item_parent_links, INDEX_NAME
  end
end