summaryrefslogtreecommitdiff
path: root/db/post_migrate/20200910131217_tmp_index_for_fixing_inconsistent_vulnerability_occurrences.rb
blob: 1985b8f1b67f5c9957041436ef5e60bc1467f514 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

class TmpIndexForFixingInconsistentVulnerabilityOccurrences < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false
  INDEX_NAME = 'tmp_index_for_fixing_inconsistent_vulnerability_occurrences'
  disable_ddl_transaction!

  def up
    # report_type: 2 container scanning
    add_concurrent_index(:vulnerability_occurrences, :id,
      where: "LENGTH(location_fingerprint) = 40 AND report_type = 2",
      name: INDEX_NAME)
  end

  def down
    remove_concurrent_index_by_name(:vulnerability_occurrences, INDEX_NAME)
  end
end