Schedule async validation of composite FK on vulnerability_occurrences

What does this MR do and why?

Following step 4 of the list partitioning guide, this schedules asynchronous validation of the NOT VALID composite foreign key fk_rails_c8661a61eb_p (partition_id, primary_identifier_id)vulnerability_identifiers(partition_id, id) on vulnerability_occurrences, added in !244081 (merged).

This matches the pattern used for vulnerability_occurrence_identifiers (fk_rails_be2e49e1d0_p, validated async in !237458 (merged) and synchronously in !240976 (merged)). Once the async validation completes on GitLab.com, a follow-up MR will validate the FK synchronously and remove the old single-column FK fk_rails_c8661a61eb.

Depends on !244081 (merged) — targets its branch for a clean diff; will be retargeted to master and rebased once !244081 (merged) merges.

Migration output

Up:

main: == 20260730141100 ValidateCompositeFkOnVulnerabilityOccurrencesAsync: migrating
main: == 20260730141100 ValidateCompositeFkOnVulnerabilityOccurrencesAsync: migrated (0.0643s)
sec: == 20260730141100 ValidateCompositeFkOnVulnerabilityOccurrencesAsync: migrating
sec: == 20260730141100 ValidateCompositeFkOnVulnerabilityOccurrencesAsync: migrated (0.0638s)

Down:

main: == 20260730141100 ValidateCompositeFkOnVulnerabilityOccurrencesAsync: reverting
main: == 20260730141100 ValidateCompositeFkOnVulnerabilityOccurrencesAsync: reverted (0.0372s)
sec: == 20260730141100 ValidateCompositeFkOnVulnerabilityOccurrencesAsync: reverting
sec: == 20260730141100 ValidateCompositeFkOnVulnerabilityOccurrencesAsync: reverted (0.0335s)

prepare_async_foreign_key_validation only records the constraint in postgres_async_foreign_key_validations, so db/structure.sql is unchanged.

References

How to set up and validate locally

  1. Run the migration and check the async validation record:

    bundle exec rails db:migrate
    psql -d gitlabhq_development_sec -c "SELECT table_name, name FROM postgres_async_foreign_key_validations;"

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.

Merge request reports

Loading
Loading