Loading
Validate partitioned FK on vulnerability_occurrences
What does this MR do and why?
Completes step 4 of the list partitioning guide for the vulnerability_occurrences → vulnerability_identifiers reference:
- Synchronously validates the composite foreign key
fk_rails_c8661a61eb_p(partition_id, primary_identifier_id)→vulnerability_identifiers(partition_id, id)(added asNOT VALIDin !244081 (merged), scheduled for async validation in !247860 (merged)). - Removes the old single-column foreign key
fk_rails_c8661a61ebonprimary_identifier_id.
This matches the pattern used for vulnerability_occurrence_identifiers in !240976 (merged) and is the final remaining step of #596858 (closed).
Dependencies:
- Depends on !244081 (merged) (adds the FK) and !247860 (merged) (schedules async validation) — targets the async-validation branch for a clean diff; will be rebased and retargeted to
masteronce they merge. - Must only be merged after the async validation of
fk_rails_c8661a61eb_phas completed on GitLab.com, so the synchronousvalidate_foreign_keyis a fast metadata-only operation.
Migration output
Up:
main: == 20260730144814 ValidateCompositeFkOnVulnerabilityOccurrences: migrating ====
main: == 20260730144814 ValidateCompositeFkOnVulnerabilityOccurrences: migrated (0.0382s)
main: == 20260730144844 RemoveOldFkOnVulnerabilityOccurrences: migrating ============
main: == 20260730144844 RemoveOldFkOnVulnerabilityOccurrences: migrated (0.0440s) ===SQL:
ALTER TABLE vulnerability_occurrences VALIDATE CONSTRAINT fk_rails_c8661a61eb_p;
ALTER TABLE vulnerability_occurrences DROP CONSTRAINT IF EXISTS fk_rails_c8661a61eb;Down: validation is kept (no-op); the old FK is restored with add_concurrent_foreign_key.
db/structure.sql was regenerated with scripts/regenerate-schema.
References
- Related to #596858 (closed)
How to set up and validate locally
-
Run the migrations and inspect the constraints:
bundle exec rails db:migrate psql -d gitlabhq_development_sec -c '\d vulnerability_occurrences' | grep fk_rails_c8661a61ebOnly
fk_rails_c8661a61eb_pshould remain, withoutNOT VALID.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.