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

20220712181304_remove_deprecated_indexes_from_todos.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4f99caa10a438f2dab45744ece82950d9b26adfa (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 RemoveDeprecatedIndexesFromTodos < Gitlab::Database::Migration[2.0]
  disable_ddl_transaction!

  PROJECTS_INDEX = 'index_todos_on_project_id_and_user_id_and_id'
  USERS_INDEX = 'index_todos_on_user_id'

  # These indexes are deprecated in favor of two new ones
  # added in a previous migration:
  #
  # * index_requirements_project_id_user_id_target_type_and_id
  # * index_requirements_user_id_and_target_type
  def up
    remove_concurrent_index_by_name :todos, PROJECTS_INDEX
    remove_concurrent_index_by_name :todos, USERS_INDEX
  end

  def down
    add_concurrent_index :todos, [:project_id, :user_id, :id], name: PROJECTS_INDEX
    add_concurrent_index :todos, :user_id, name: USERS_INDEX
  end
end