Adjust vulnerability backup model foreign keys
Summary
While implementing the tracking vulnerabilities on the multiple branches feature, some of the model schemas have been changed. An example is the Vulnerabilities::StateTransition model. This model was associated with the Vulnerability model, but it's going to be associated with the Vulnerabilities::Finding model once the feature is complete. This requires the backup_vulnerability_state_transitions table schema to be updated, as it currently has the vulnerability_id foreign key.
Affected Tables
After investigation, the following 6 backup tables need to be updated to include finding_id column mapping for vulnerability_occurrence_id:
| Backup Table | Backup Model | Source Model |
|---|---|---|
backup_vulnerability_state_transitions |
Backups::VulnerabilityStateTransition |
Vulnerabilities::StateTransition |
backup_vulnerability_severity_overrides |
Backups::VulnerabilitySeverityOverride |
Vulnerabilities::SeverityOverride |
backup_vulnerability_issue_links |
Backups::VulnerabilityIssueLink |
Vulnerabilities::IssueLink |
backup_vulnerability_merge_request_links |
Backups::VulnerabilityMergeRequestLink |
Vulnerabilities::MergeRequestLink |
backup_vulnerability_external_issue_links |
Backups::VulnerabilityExternalIssueLink |
Vulnerabilities::ExternalIssueLink |
backup_vulnerability_reads |
Backups::VulnerabilityRead |
Vulnerabilities::Read |
Implementation
For each table:
- Add database migration to add
finding_id bigintcolumn to the backup table - Update the backup model's
column_mappingto includevulnerability_occurrence_id: :finding_id
This follows the existing pattern used by other finding-related backup tables like backup_finding_flags.
Edited by Gregory Havenga