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

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

class AddIndexProjectIdOnScanFindingApprovalProjectRules < Gitlab::Database::Migration[2.0]
  INDEX_NAME_ALL = 'scan_finding_approval_project_rule_index_project_id'
  INDEX_NAME_28D = 'scan_finding_approval_project_rule_index_created_at_project_id'
  SCAN_FINDING_REPORT_TYPE = 4

  disable_ddl_transaction!

  def up
    add_concurrent_index :approval_project_rules, %i[created_at project_id],
      where: "report_type = #{SCAN_FINDING_REPORT_TYPE}", name: INDEX_NAME_28D

    add_concurrent_index :approval_project_rules, :project_id,
      where: "report_type = #{SCAN_FINDING_REPORT_TYPE}", name: INDEX_NAME_ALL
  end

  def down
    remove_concurrent_index_by_name :approval_project_rules, INDEX_NAME_ALL
    remove_concurrent_index_by_name :approval_project_rules, INDEX_NAME_28D
  end
end