[go: up one dir, main page]

Skip to content

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:

  1. 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))
  2. Confusion: Having both id and vulnerability_id columns where only vulnerability_id is used as the primary key creates confusion
  3. Unnecessary Storage: The id column serves no functional purpose since all operations use vulnerability_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 down method that recreates the column, but note that original id values cannot be restored

References

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

Merge request reports

Loading