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

20220613095911_create_confidential_notes_index_on_id.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 80c26c3ea8ab1bfc597d5d4e903685ee66f0fddd (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 CreateConfidentialNotesIndexOnId < Gitlab::Database::Migration[2.0]
  OLD_INDEX_NAME = 'index_notes_on_confidential'
  INDEX_NAME = 'index_notes_on_id_where_confidential'

  disable_ddl_transaction!

  def up
    remove_concurrent_index_by_name :notes, name: OLD_INDEX_NAME
    add_concurrent_index :notes, :id, where: 'confidential = true', name: INDEX_NAME
  end

  def down
    # we don't have to re-create OLD_INDEX_NAME index
    # because it wasn't used yet, also its creation might be expensive
    remove_concurrent_index_by_name :notes, name: INDEX_NAME
  end
end