Class: Gitlab::BackgroundMigration::RemoveOccurrencePipelinesAndDuplicateVulnerabilitiesFindings
- Inherits:
-
Object
- Object
- Gitlab::BackgroundMigration::RemoveOccurrencePipelinesAndDuplicateVulnerabilitiesFindings
- Defined in:
- lib/gitlab/background_migration/remove_occurrence_pipelines_and_duplicate_vulnerabilities_findings.rb
Overview
This migration will look for Vulnerabilities::Finding objects that would have a duplicate UUIDv5 if the UUID was recalculated. Then it removes Vulnerabilities::FindingPipeline objects associated with those Findings. We can’t just drop those Findings directly since the cascade drop will timeout if any given Finding has too many associated FindingPipelines
Defined Under Namespace
Classes: VulnerabilitiesFinding, VulnerabilitiesFindingPipeline
Instance Method Summary collapse
-
#perform(start_id, end_id) ⇒ Object
rubocop:enable Gitlab/NamespacedClass, Style/Documentation.
Instance Method Details
#perform(start_id, end_id) ⇒ Object
rubocop:enable Gitlab/NamespacedClass, Style/Documentation
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gitlab/background_migration/remove_occurrence_pipelines_and_duplicate_vulnerabilities_findings.rb', line 19 def perform(start_id, end_id) ids_to_look_for = findings_that_would_produce_duplicate_uuids(start_id, end_id) ids_to_look_for.each do |finding_id| VulnerabilitiesFindingPipeline.where(occurrence_id: finding_id).each_batch(of: 1000) do |pipelines| pipelines.delete_all end end VulnerabilitiesFinding.where(id: ids_to_look_for).delete_all mark_job_as_succeeded(start_id, end_id) end |