Skip to content

Replace foreign keys to use the partitioned table

Marius Bobin requested to merge 382033-routing-table-foreign-keys into master

What does this MR do and why?

Related to #414396 (closed)

After partitioning ci_builds we need to update all the tables that reference it to use the routing table instead. This adds the invalid FKs and schedule the async validation for them.

Next steps

  1. Synchronous validation: !122087 (merged)
  2. Finish adding the FKs between partitioned tables: !122097 (closed)
  3. Drop old FKs and rename the new ones: !122102 (closed)

How to set up and validate locally

  1. ./scripts/regenerate-schema to run migrations in the test env
  2. RAILS_ENV=test bin/rails runner "Feature.enable(:database_async_foreign_key_validation)" for the next step
  3. RAILS_ENV=test bin/rails gitlab:db:validate_async_constraints:all to validate the constraints
  4. RAILS_ENV=test bin/rails db:migrate to dump the schema changes
  5. NOT VALID lines will be removed from the structure.sql file

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #382033 (closed)

Edited by Marius Bobin

Merge request reports