Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20210529164247_change_iterations_title_uniqueness_index.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 47e7e2c757dd9da0cc45bc5245e90c3df3bdde3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

class ChangeIterationsTitleUniquenessIndex < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  INDEX_NAME = 'index_sprints_on_iterations_cadence_id_and_title'
  OLD_INDEX_NAME = 'index_sprints_on_group_id_and_title'

  disable_ddl_transaction!

  def up
    add_concurrent_index :sprints, [:iterations_cadence_id, :title], name: INDEX_NAME, unique: true
    remove_concurrent_index_by_name :sprints, OLD_INDEX_NAME
  end

  def down
    # noop
    # rollback would not work as we can have duplicate records once the unique `index_sprints_on_group_id_and_title` index is removed
  end
end