Change routes.namespace_id LFK to a regular foreign key
In Convert routes.namespace_id to a loose foreign key (!130096 - merged), we changed the routes.namespace_id column from a strict foreign key to a loose foreign key. We want to reverse this change because now the namespaces table and the routes table belong to the gitlab_main_cell schema. See !178549 (comment 2309305911).
Implementation guide
-
MR 1:
- In a standard migration, add the FK with
valid: falseback that was removed in !130096 (diffs) with cascade delete. - Remove the loose foreign key definition from
config/gitlab_loose_foreign_keys.yml.
- In a standard migration, add the FK with
-
MR 2:
- In a post-deploy migration, query the LFK deleted_records table where the
table name = 'public.namespaces' and status = 1. For each ID, look up the route record and delete it. - In a post-deploy migration, validate the above FK.
- In a post-deploy migration, query the LFK deleted_records table where the
Edited by Abdul Wadood