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

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

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

  DOWNTIME = false

  disable_ddl_transaction!

  LEGACY_INDEX_NAME = "index_notes_on_noteable_id_and_noteable_type"
  NEW_INDEX_NAME = "index_notes_on_noteable_id_and_noteable_type_and_system"

  def up
    add_concurrent_index :notes, [:noteable_id, :noteable_type, :system], name: NEW_INDEX_NAME

    remove_concurrent_index_by_name :notes, LEGACY_INDEX_NAME
  end

  def down
    add_concurrent_index :notes, [:noteable_id, :noteable_type], name: LEGACY_INDEX_NAME

    remove_concurrent_index_by_name :notes, NEW_INDEX_NAME
  end
end