diff options
Diffstat (limited to 'db/post_migrate/20220607082910_add_sync_tmp_index_for_potentially_misassociated_vulnerability_occurrences.rb')
-rw-r--r-- | db/post_migrate/20220607082910_add_sync_tmp_index_for_potentially_misassociated_vulnerability_occurrences.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/db/post_migrate/20220607082910_add_sync_tmp_index_for_potentially_misassociated_vulnerability_occurrences.rb b/db/post_migrate/20220607082910_add_sync_tmp_index_for_potentially_misassociated_vulnerability_occurrences.rb new file mode 100644 index 00000000000..fe4ffbf6cc3 --- /dev/null +++ b/db/post_migrate/20220607082910_add_sync_tmp_index_for_potentially_misassociated_vulnerability_occurrences.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AddSyncTmpIndexForPotentiallyMisassociatedVulnerabilityOccurrences < 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 + add_concurrent_index :vulnerability_occurrences, + [:id, :scanner_id], + where: CLAUSE, + name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :vulnerability_occurrences, INDEX_NAME + end +end |