Prevent multiple users from a source being mapped to the same user on destination
What does this MR do and why?
This MR adds a model validation and database constraint to ensure reassign_to_user is reassigned only once per import, i.e., reassign_to_user_id is unique across namespace_id, source_hostname and import_type. This MR also adds a humanized attribute name to reassign_to_user_id so that model errors returned from the reassign mutation are readable.
Database and data validation concerns
The migrations in this MR are on import_source_users, which does not have any rows on production and has not yet been released in any version of GitLab. Developers may be impacted if they have reassiged a real user to more than one placeholder on their local instance.
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.
Screenshots or screen recordings
| Before | After |
|---|---|
| No error on duplicate reassignment | Error that prevents duplicate reassignment |
![]() |
![]() |
How to set up and validate locally
- Fetch the branch with user mapping integrated in direct transfer or other importer and follow its instructions to import a group to your local instance.
- Switch back to this branch
- Assign a real user to a placeholder user by going to the top-level imported group's members page.
- Assign a real user to a placeholder user.
- Assign the same real user to another placeholder user.
- Verify that the duplicate assignment shows an error and the real user is not reassigned twice.
Related to #473976 (closed)

