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

20221205134448_set_index_for_issues_health_status_ordering.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 38426c3ba156b5b6957fe74fa21103e8ee40b467 (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
25
# frozen_string_literal: true

class SetIndexForIssuesHealthStatusOrdering < Gitlab::Database::Migration[2.1]
  disable_ddl_transaction!

  INDEX_NAME_DESC = 'index_on_issues_health_status_desc_order'
  INDEX_NAME_ASC = 'index_on_issues_health_status_asc_order'

  def up
    add_concurrent_index :issues,
      [:project_id, :health_status, :id, :state_id, :issue_type],
      order: { health_status: 'DESC NULLS LAST', id: :desc },
      name: INDEX_NAME_DESC

    add_concurrent_index :issues,
      [:project_id, :health_status, :id, :state_id, :issue_type],
      order: { health_status: 'ASC NULLS LAST', id: :desc },
      name: INDEX_NAME_ASC
  end

  def down
    remove_concurrent_index_by_name :issues, INDEX_NAME_DESC
    remove_concurrent_index_by_name :issues, INDEX_NAME_ASC
  end
end