Delete dupes before updating severities
This is to avoid any integrity violations in migration
@@ -47,6 +47,13 @@ def merge_cvss_score_and_vector_severities(apps, _):
process_severity(severity, updated_severities_to_save, redundant_severity_ids_to_delete)
# finally batch update and delete
+
+ # batch delete the collected vecto severity ids
+ deleted, _ = VulnerabilitySeverity.objects.filter(
+ id__in=redundant_severity_ids_to_delete
+ ).delete()
+ print(f"Deleted {deleted} CVSS VulnerabilitySeverity")
+
# update in bulk, 1000 at a time
updated = VulnerabilitySeverity.objects.bulk_update(
objs=updated_severities_to_save.values(),
@@ -59,12 +66,6 @@ def merge_cvss_score_and_vector_severities(apps, _):
)
print(f"Updated {updated} CVSS VulnerabilitySeverity")
- # batch delete the collected vecto severity ids
- deleted, _ = VulnerabilitySeverity.objects.filter(
- id__in=redundant_severity_ids_to_delete
- ).delete()
- print(f"Deleted {deleted} CVSS VulnerabilitySeverity")
-
leftover_vectors = VulnerabilitySeverity.objects.filter(
scoring_system__in=cvss_vector_systems
).count()
