Support consolidating groups and projects during direct transfer import
Summary
Direct Transfer currently does not support consolidating sub-groups and projects during the import process. When users attempt to import projects from different source groups into the same destination parent group, they may encounter PG::UniqueViolation errors due to conflicting Epic IIDs.
This feature request proposes adding support for consolidation during the transfer, which would be the 3rd option alongside the existing options of consolidating before or after the transfer.
Problem
When importing multiple projects that belong to different source groups into the same destination parent group:
- If the source projects have issues assigned to epics in their respective parent groups
- And those epics happen to have the same IID (but different titles/content)
- The import fails with errors like:
PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_issues_on_namespace_id_iid_unique" DETAIL: Key (namespace_id, iid)=(2322, 5) already exists.
This occurs because when Direct Transfer creates the epic's synced WorkItem, it conflicts with an existing Epic WorkItem that has the same IID in the destination group.
Example scenario
Source structure:
- Group: 'group-a'
- Epic IID: 1, title: 'Epic A'
- Project: 'project-a'
- Issue assigned to 'Epic A'
- Group: 'group-b'
- Epic IID: 1, title: 'Epic B'
- Project: 'project-b'
- Issue assigned to 'Epic B'
Desired destination structure (consolidating into same parent):
- Group: 'destination-group'
- Epic IID: 1, title: 'Epic A'
- Epic IID: ?, title: 'Epic B' # IID conflict!
- Project: 'project-a'
- Project: 'project-b'
Current workaround
Users must either:
- Consolidate before transfer: Reorganize the source instance structure before migrating
- Consolidate after transfer: Import maintaining the original structure, then manually reorganize on the destination
- Avoid consolidation: Keep the original group structure on the destination
None of these options are ideal for users who want to restructure their organization during migration.
Proposal
Enhance Direct Transfer to handle IID conflicts when consolidating groups/projects during import by:
- Detecting when an epic with a conflicting IID already exists in the destination namespace
- Assigning a new, non-conflicting IID to the imported epic
- Properly linking the imported issues to the newly created epic
Related issues
- Originated from gitlab-com/request-for-help#4113