Update Direct Transfer to skip banned user contributions
What does this MR do and why?
This MR updates Direct Transfer to add an optional flag migrate_banned_contributions to optionally migrate contributions of banned users. Defaults to false. If set to false, then the following relations are not going to be migrated:
- Projects. They are marked as Skipped on migration history page (see screenshots below)
- Issues
- Merge requests
- Notes
If flag is set to true, then all these relations are going to be migrated.
Mentions #508111
Migration output
Up
main: == [advisory_lock_connection] object_id: 129460, pg_backend_pid: 36322
main: == 20250320150755 AddMigrateBannedContributionsColumnToBulkImportEntities: migrating
main: -- add_column(:bulk_import_entities, :migrate_banned_contributions, :boolean, {:default=>false, :null=>false})
main: -> 0.0032s
main: == 20250320150755 AddMigrateBannedContributionsColumnToBulkImportEntities: migrated (0.0070s)
main: == [advisory_lock_connection] object_id: 129460, pg_backend_pid: 36322
ci: == [advisory_lock_connection] object_id: 129460, pg_backend_pid: 36714
ci: == 20250320150755 AddMigrateBannedContributionsColumnToBulkImportEntities: migrating
ci: -- add_column(:bulk_import_entities, :migrate_banned_contributions, :boolean, {:default=>false, :null=>false})
ci: -> 0.0037s
ci: == 20250320150755 AddMigrateBannedContributionsColumnToBulkImportEntities: migrated (0.0140s)
ci: == [advisory_lock_connection] object_id: 129460, pg_backend_pid: 36714
Down
main: == [advisory_lock_connection] object_id: 129460, pg_backend_pid: 35486
main: == 20250320150755 AddMigrateBannedContributionsColumnToBulkImportEntities: reverting
main: -- remove_column(:bulk_import_entities, :migrate_banned_contributions, :boolean, {:default=>false, :null=>false})
main: -> 0.0049s
main: == 20250320150755 AddMigrateBannedContributionsColumnToBulkImportEntities: reverted (0.0121s)
ci: == [advisory_lock_connection] object_id: 129460, pg_backend_pid: 35881
ci: == 20250320150755 AddMigrateBannedContributionsColumnToBulkImportEntities: reverting
ci: -- remove_column(:bulk_import_entities, :migrate_banned_contributions, :boolean, {:default=>false, :null=>false})
ci: -> 0.0035s
ci: == 20250320150755 AddMigrateBannedContributionsColumnToBulkImportEntities: reverted (0.0155s)
ci: == [advisory_lock_connection] object_id: 129460, pg_backend_pid: 35881
References
Screenshots or screen recordings
| Source | migrate_banned_contributions: false | migrate_banned_contributions: true | |
|---|---|---|---|
| Project |
|
|
|
| Merge Request |
|
|
|
| Issue |
|
|
|
| Note |
|
|
|
How to set up and validate locally
- Create a top level group and a project in it
- Add a member to the group that's going to be banned
- Impersonate the user and create a project by the user
- With the same user, in the project that's not created by this user, create an issue, a merge request and a comment
- With admin user, go to user admin page and ban it
- With the user that created the group, perform Direct Transfer of this group to a new location (can be done within the same instance) by going to
/groups/new#import-group-panepage. Make sure Direct Transfer is enabled in admin settings. - Enable
hidden_notes&hide_merge_requests_from_banned_usersfeature flags. - Check 'Import banned contributions' check box and perform the migration of the group. Validate that banned user contributions are carried over. Banned project should have migrated, an issue, a merge request and a comment from banned user should be present.
- Perform another migration, this time with 'Import banned contributions' unchecked. Verify banned contributions are not migrated.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by George Koltsov












