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

20230104220137_reindex_vuln_reads_on_default_branch_with_common_query.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 114a1a84fa065a66c7531b180a6d361cd25fb5a6 (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
26
# frozen_string_literal: true

class ReindexVulnReadsOnDefaultBranchWithCommonQuery < Gitlab::Database::Migration[2.1]
  INDEX_NAME = 'index_vuln_reads_common_query_on_resolved_on_default_branch'

  COLUMNS = %i[project_id state report_type vulnerability_id]

  disable_ddl_transaction!

  def up
    add_concurrent_index(
      :vulnerability_reads,
      COLUMNS,
      name: INDEX_NAME,
      where: 'resolved_on_default_branch IS TRUE',
      order: { vulnerability_id: :desc }
    )
  end

  def down
    remove_concurrent_index_by_name(
      :vulnerability_reads,
      INDEX_NAME
    )
  end
end