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

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

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

  DOWNTIME = false

  disable_ddl_transaction!

  OLD_INDEX_NAME = 'index_issue_email_participants_on_issue_id_and_email'
  NEW_INDEX_NAME = 'index_issue_email_participants_on_issue_id_and_lower_email'

  def up
    # This table is currently empty, so no need to worry about unique index violations
    add_concurrent_index :issue_email_participants, 'issue_id, lower(email)', unique: true, name: NEW_INDEX_NAME
    remove_concurrent_index_by_name :issue_email_participants, OLD_INDEX_NAME
  end

  def down
    add_concurrent_index :issue_email_participants, [:issue_id, :email], unique: true, name: OLD_INDEX_NAME
    remove_concurrent_index_by_name :issue_email_participants, NEW_INDEX_NAME
  end
end