Associate security_scans with vulnerability_scanners
What does this MR do?
Implements the first 3 steps of the implementation plan from #371642:
- Adds a new
scanner_idcolumn to thesecurity_scanstable - Adjusts the
Security::StoreScanServiceto set this column when creating security scans - Adds comprehensive test coverage for the implementation
This change establishes the relationship between security_scans and vulnerability_scanners, which will support the metric gathering described in !212779.
Database changes
- Adds
scanner_idbigint column tosecurity_scanstable - Adds index on
scanner_idcolumn - Foreign key will be added after background migration backfills existing records
Implementation details
- Updates
Security::Scanmodel to includebelongs_to :vulnerability_scannerassociation - Modifies
Security::StoreScanServiceto setscanner_idwhen creating scans - Updates
scannermethod to use the association when available, falling back to existing lookup logic - Adds comprehensive specs for model associations and service behavior