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
id
as a special attribute that maps to the primary key, causing issues with bulk insert operations (as seen in !209592 (merged)) -
Confusion: Having both
id
andvulnerability_id
columns where onlyvulnerability_id
is used as the primary key creates confusion -
Unnecessary Storage: The
id
column serves no functional purpose since all operations usevulnerability_id
id
column:
Benefits of removing the - 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
down
method that recreates the column, but note that originalid
values 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