Transfer TLG to Org: Dynamically migrate project-associated org-sharded tables
Summary
Implement a dynamic approach to migrate project-associated models when transferring a top-level group to a new organization, similar to the approach used in !218968 (merged) for user-associated models.
Background
MR !218968 (merged) introduced a dynamic model discovery approach in Organizations::Transfer::UsersService that:
- Finds all
ApplicationRecorddescendants with exactly oneUserassociation AND oneOrganizations::Organizationassociation - Dynamically determines the foreign key via reflection
- Batch updates
organization_idfor rows matching the transferring user IDs
This issue applies the same pattern for project-associated models.
Proposal
Create a mechanism (new service or extend existing) that:
- Discovers models with exactly one
Projectassociation AND oneOrganizations::Organizationassociation - Excludes models that need special handling (e.g.,
Projectitself,Note,Snippet) - Uses reflection to find the project foreign key (
project_id, etc.) - Updates
organization_idfor rows belonging to projects being transferred
Candidate Models (to verify at implementation)
Based on codebase analysis, models that may be migratable:
PoolRepositorySnippetRepositorySlackIntegrationBulkImports::EntityIntegrations::SlackWorkspace::IntegrationApiScope- EE:
PushRule,Vulnerabilities::Export,Dependencies::DependencyListExport,Ai::Catalog::Item
Models to skip (handled separately or special logic needed)
Project(already handled inGroupsService)Note(has author replacement logic)Snippet/ProjectSnippet(complex handling)Todo(has bot author logic)Label(marked asno_work_needed)
Implementation Notes
- Reference:
app/services/organizations/transfer/users_service.rbfor the pattern - Service location TBD: could be new service or extension of
GroupsService - Verify index exists on project foreign key for all affected models
- Ensure
spec/lib/gitlab/organizations/organization_transfer_support_spec.rbpasses, update the relevantdb/docs/*.ymlfiles to mark tables asorganization_transfer_support: supported
Acceptance Criteria
- Dynamic model discovery implemented for project-associated models
- Specs validate all discovered models are updated during transfer
-
db/docs/*.ymlfiles updated for affected tables - Update
config/organizations/transfer_support.yml— change status from issue URL tosupportedfor affected tables
References
- !218968 (merged) - Dynamic approach for user-associated models
- gitlab-com/gl-infra&2010 (closed) - Parent epic
Edited by tim mccarthy