[go: up one dir, main page]

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:

  1. Projects. They are marked as Skipped on migration history page (see screenshots below)
  2. Issues
  3. Merge requests
  4. 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

image

Source migrate_banned_contributions: false migrate_banned_contributions: true
Project image image image
Merge Request image image image
Issue image image image
Note image image image

How to set up and validate locally

  1. Create a top level group and a project in it
  2. Add a member to the group that's going to be banned
  3. Impersonate the user and create a project by the user
  4. With the same user, in the project that's not created by this user, create an issue, a merge request and a comment
  5. With admin user, go to user admin page and ban it
  6. 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-pane page. Make sure Direct Transfer is enabled in admin settings.
  7. Enable hidden_notes & hide_merge_requests_from_banned_users feature flags.
  8. 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.
  9. 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

Merge request reports

Loading