0

My custom Drupal 7 to Drupal 8 migration correctly follows dependencies and first migrates users, then articles. The problem is that it fails to import user IDs into the 'uid' field and leaves it at '0'. For uid processing, I use the following YAML snipped. Note that 'luxus_users' is the user migration that works fine.

process:
    uid:
         plugin: iterator
         source: uid
         process:
           target_id:
               plugin: migration
               migration: luxus_users
               source: uid

I hoped would work for me as similar one for file migration already works for me.

field_logo:
     plugin: iterator
     source: field_logo
     process:
       target_id:
         plugin: migration
         migration: luxus_files
         source: fid

3 Answers 3

1

The difference is that the fid you're migrating is part of a reference field with an internal structure, which makes 'iterator' appropriate. For nodes, however, uid is a simple property, not a field array, so you can map it more directly:

process:
  uid:
    plugin: migration
    migration: luxus_users
    source: uid
8
  • Thanks for your answer. I tried your direct approach before a tried the iterator one, but with no success. While all users are migrated correctly including user pictures, the uid is not imported to Drupal 8 content nodes. Even hard-wired 'default_value' is not imported...Looks like my uid field is cursed :-) Commented May 30, 2017 at 20:18
  • Oops, my example was wrong, I kept the 'process:' from the iterator, I've fixed my example in my original reply.
    – Mike Ryan
    Commented May 31, 2017 at 14:23
  • Yes, I noticed that. Still even the 'fixed' version does not assign a uid to an article, leaving it at 0. Commented Jun 2, 2017 at 8:51
  • It's hard to imagine then why it's not working for you. Have you looked at migrate_map_luxus_users to make sure it does have proper mappings from D7 uids (sourceid1) to D8 uids (destid1)?
    – Mike Ryan
    Commented Jun 3, 2017 at 14:28
  • Yes, the migrate_map_luxus_users table has the correct mappings. Commented Jun 5, 2017 at 6:00
1

The following piece of code works for me now:

uid:
  plugin: migration
  migration: luxus_users
  source: node_uid

Dont know why all the examples refer to 'uid' which is nto part of the $row...

1
  • The variable has traditionally been named "uid" - the database column is called "uid", the variable on the node entity has always been named "uid", so everyone expects it to be "uid". This has tripped me up many times. Commented May 25, 2023 at 10:15
0

Accepted answer did not solve my issue . But the answer from @Mike-Ryan helped me to go into right direction.

migration plugin is deprecated so I used migration_lookup plugin which helped me to solve the issue.

My migration mapping definition as follows :

  uid:
    -
      plugin: migration_lookup
      migration: luxus_users
      source: uid

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.