I have a Drupal 7 site with a bunch of users. I want to migrate the users to Drupal 8 but not any of the content so I'm writing a crosswalk. Drupal 8 has uuid in the users table. Is there a way I can compute this or can I just set it to NULL? Thanks!
1 Answer
No, cannot be empty.
You can generate one with
$uuid_service = \Drupal::service('uuid');
$uuid = $uuid_service->generate();
If you use User::create it will automatically generate one for you.
Drupal\user\Entity\User::create([
'uid' => $uid,
'name' => '$user_name,
'mail' => $email,
'roles' => [],
'pass' => [
'value' => $hashed_drupal_7_password,
'pre_hashed' => TRUE,
],
'status' => 1,
])->save();
Rather than code it from scratch. The proper, Drupal way, to migrate is using all of these:
- core's migrate
- migrate plus
- migrate tools
I suggest your read this article A Quick Guide to Migrating Drupal Content from D7 to D8 which goes over how to migrate users and other scenarios.
-
Even easier, I discovered the Universally Unique IDentifier module for Drupal 7. That generated uuids that I can just port over.– ChanelCommented Oct 23, 2020 at 14:34