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

20221115120602_add_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: d7d861387fde13d0c4885c6560a4a716591fab8e (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 AddIndexForIssuesHealthStatusOrdering < Gitlab::Database::Migration[2.0]
  INDEX_NAME_DESC = 'index_on_issues_health_status_desc_order'
  INDEX_NAME_ASC = 'index_on_issues_health_status_asc_order'

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

    prepare_async_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
    unprepare_async_index :issues, INDEX_NAME_DESC
    unprepare_async_index :issues, INDEX_NAME_ASC
  end
end