Skip to content

Set imported_from for Direct Transfer objects

Luke Duncalfe requested to merge 424454-backend into master

What does this MR do and why?

This MR sets the imported_from for objects imported in Direct Transfer. The objects that need this to be set are listed in #424454 (closed).

There is one spot related to Epic -> WorkItem syncing in EpicObjectCreator where #persist_relation has this logic and will use Epics::CreateService. This is being addressed in a follow-up MR !152575 (merged).

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.

How to set up and validate locally

Checkout this branch, restart workers, and initiate a new Direct Transfer.

It can be easier to use the API to do this.

Example:

curl --request POST \
  --url "http://gdk.test:3000/api/v4/bulk_imports" \
  --header "content-type: application/json" \
  --header "PRIVATE-TOKEN: <DEVELOPMENT_PAT>" \
  --data "{
    \"configuration\": {
      \"url\": \"https://gitlab.com/\",
      \"access_token\": \"<PRODUCTION_PAT>\"
    },
    \"entities\": [
      {
        \"source_full_path\": \"source-group\",
        \"source_type\": \"group_entity\",
        \"destination_slug\": \"new-imported-group-full-path\",
        \"destination_namespace\": \"full-path-of-group-to-import-into\",
        \"migrate_projects\": true
      }
    ]
  }"

Verify that all data listed in #424454 (closed) has imported_from set to "gitlab_migration".

Example:

epic = Epic.last
epic.imported_from # => "gitlab_migration"
epic.notes.pluck(:imported_from) # => ["gitlab_migration", ... ]

project = Project.last 

project.snippets.pluck(:imported_from) # => ["gitlab_migration"]

project.issues.pluck(:imported_from) # => ["gitlab_migration", ... ]
project.issues.first.notes.pluck(:imported_from) # => ["gitlab_migration", ... ]
project.issues.first.notes.pluck(:imported_from) # => ["gitlab_migration", ... ]
project.issues.first.resource_milestone_events.pluck(:imported_from)  # => ["gitlab_migration", ... ]
project.issues.first.resource_label_events.pluck(:imported_from) # => ["gitlab_migration", ... ]
project.issues.first.designs.pluck(:imported_from) # => ["gitlab_migration", ... ]
project.issues.first.designs.first.notes.pluck(:imported_from) # => ["gitlab_migration", ... ]

project.merge_requests.pluck(:imported_from) # => ["gitlab_migration", ... ]
project.merge_requests.first.notes.pluck(:imported_from) # => ["gitlab_migration", ... ]

Related to #424454 (closed)

Edited by Luke Duncalfe

Merge request reports