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

  1. MR 1:
    1. In a standard migration, add the FK with valid: false back that was removed in !130096 (diffs) with cascade delete.
    2. Remove the loose foreign key definition from config/gitlab_loose_foreign_keys.yml.
  2. MR 2:
    1. 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.
    2. In a post-deploy migration, validate the above FK.
Edited Feb 18, 2025 by Abdul Wadood
Assignee Loading
Time tracking Loading