Remove id column from vulnerability_reads table
What does this MR do and why?
This MR adds a database migration to remove the id column from the vulnerability_reads table.
The vulnerability_reads table currently has both an id column and uses vulnerability_id as the primary key. This design causes several issues:
-
Rails 7.2 Compatibility: Rails treats
idas a special attribute that maps to the primary key, causing issues with bulk insert operations (as seen in !209592 (merged)) -
Confusion: Having both
idandvulnerability_idcolumns where onlyvulnerability_idis used as the primary key creates confusion -
Unnecessary Storage: The
idcolumn serves no functional purpose since all operations usevulnerability_id
Benefits of removing the id column:
- Resolves Rails 7.2 bulk insert compatibility issues
- Reduces table size and index overhead
- Eliminates confusion about which column is the actual primary key
- Simplifies the model structure
Database Impact
-
Table:
vulnerability_reads -
Operation:
DROP COLUMN id -
Reversibility: The migration includes a
downmethod that recreates the column, but note that originalidvalues cannot be restored
References
- Related issue: #357262
- Context from MR: !209592 (merged) (Fix bulk insert of vulnerability reads in Rails 7.2)
MR acceptance checklist
This MR:
-
Includes a database migration -
Has been tested for reversibility -
Addresses a specific Rails 7.2 compatibility issue -
Simplifies the data model by removing an unused column