Fix organization_id inconsistencies
What does this MR do and why?
Organizations UI is still behind a feature flag and only available for a few GitLab team members. However, we did find some inconsistencies: a few project and namespace records have an organization_id that does not match the organization_id of the group they belong to.
This MR introduces a post-migrate migration that fixes those:
- First, it finds
namespaces
records with an id other than 1 - For each of these records
- It will update the organization of the projects that belong to the namespace
- It will update the organization of the child groups that belong to the namespace
Query Plans
SELECT id, organization_id, parent_id FROM namespaces WHERE organization_id > 1 AND parent_id IS NULL
SELECT id, organization_id, type FROM namespaces WHERE parent_id = ?
UPDATE namespaces SET organization_id = ? WHERE parent_id = ? AND organization_id != ?
UPDATE projects SET organization_id = ? WHERE namespace_id = ? AND organization_id != ?
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #480830 (closed)
Edited by Rutger Wessels