Skip to content
Snippets Groups Projects
Commit 05c2f66d authored by Dominic Bauer's avatar Dominic Bauer :speech_balloon: Committed by Mayra Cabrera
Browse files

Add tmp index for vuln findings with potentially mismatched scanners

Changelog: changed
parent ea05f4c9
No related branches found
No related tags found
1 merge request!91488Add asynchronous temporary index for vulnerability findings with potentially mismatched scanners
# frozen_string_literal: true
class AddTmpIndexForPotentiallyMisassociatedVulnerabilityOccurrences < Gitlab::Database::Migration[2.0]
INDEX_NAME = "tmp_index_vulnerability_occurrences_on_id_and_scanner_id"
REPORT_TYPES = { cluster_image_scanning: 7, generic: 99 }.freeze
CLAUSE = "report_type IN (#{REPORT_TYPES.values.join(',')})"
disable_ddl_transaction!
def up
prepare_async_index :vulnerability_occurrences,
[:id, :scanner_id],
where: CLAUSE,
name: INDEX_NAME
end
def down
unprepare_async_index_by_name :vulnerability_occurrences, INDEX_NAME
end
end
ecab80f469d2aea061b5c8371a243e4b6686d637c3df284f23e575606ef8c1a6
\ No newline at end of file
# frozen_string_literal: true
require "spec_helper"
require_migration!
RSpec.describe AddTmpIndexForPotentiallyMisassociatedVulnerabilityOccurrences do
let(:async_index) { Gitlab::Database::AsyncIndexes::PostgresAsyncIndex }
let(:index_name) { described_class::INDEX_NAME }
it "schedules the index" do
reversible_migration do |migration|
migration.before -> do
expect(async_index.where(name: index_name).count).to be(0)
end
migration.after -> do
expect(async_index.where(name: index_name).count).to be(1)
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment