(BE) Allow importing user to choose to import memberships or not
This is the backend portion of this feature. The frontend work will be tracked in #477734 (closed)
Problem
Currently we import user memberships together with user contributions. It's not possible to separate contributions and memberships mapping, but it would be beneficial for users to be able to do that. There are cases when importing users don't want to move over all members.
Proposal
We have migrate_projects boolean in bulk_import_entities table to indicate if said entity should or should not include projects.
The ask is to have a single flag that applied to the entire migration, without the granularity per group. So we can do something similar here, add migrate_memberships flag, that applies to the entire migration. For this we can do:
- Add a new db column in
bulk_import_entities table calledbulk_import_configurationsmigrate_membershipsdefaulttrue. - Update MembersPipeline to skip membership creation when the new property is
false. This could be done in a way similar to how theProjectEntitiesPipelineis conditionally included. - Update
BulkImports::CreateServiceto accept the new argument, and to set it on the configuration here. - Update API endpoint to accept a new optional argument (in this block) called
migrate_memberships. Documentation for this new argument should be added todoc/api/bulk_imports.md. - Update the API to pass the argument to the service here and the controller to allow the new param and pass the argument to the service here.
Design and copy
See the frontend issue in #477734 (closed)
Emails and banners
We need to show different messages in emails and in confirmation banners - we should not talk about mapping contributions and memberships, but only contributions.
Docs - To be added in frontend ticket
Here's proposal of docs update - can be used as starting point:
Paragraph title: Opt out of importing memberships
There might be cases when you don't want to import user memberships that are on the source instance. For example, on the source instance the groups or projects that you import have 200 members, but on the destination GitLab instance you want to have only 50 members.
Before the import begins, opt out of importing memberships by clearing the Import user memberships checkbox. If you clear the checkbox, no memberships are imported for the groups and projects that are migrated.
The Import user memberships checkbox is available on the page where you choose groups or projects to be imported.
After the import completes, you can add members to groups and projects at will.