Member Information CT as User Entity¶
We are doing a tricky thing here which is migrate a node CT using User Entity as destination. So we are converting the node to a user on-the-fly while we migrate its ‘nodes’ that will become ‘users’ and all its fields, field instances, field formatter widget, etc…
Pre-migrate tasks¶
Pre-migrate D8 manual tweaks¶
Before running the acvo_d6_user_profile migration, we must apply some manual tweaks into D8 site so things run smooth:
- Manually create (or config export/import from a previously built site) Address fields. We are using these to ‘convert’ D6 textfields related to Address into proper ‘address fields’.
We need 5 ‘address fields’ field with following subfields available:
- Administrative area
- Locality
- Postal code
- Address line 1
- Address line 2
- Company
-
Manually create (or export/import from a previously built site) a
countryfield. Field machine name MUST befield_vendor_country, to match the field mapping in User migration. We need this country field because we are converting a taxonomy field in D6 into a proper ‘Country Field’ (provided by Address module). -
Uncheck the “Notify user when account is activated” checkbox in admin/config/people/accounts so when migrating and creating user accounts no emails are sent.
- On the
acvo_d6_user_profilemigration template, keep the ‘upgrade_d6_user_settings’ migration commented out to avoid re-setting the above.
Tip
Please remember to check machine names in migrate_plus.migration.acvo_d6_user_profile.yml file!
Pre-migrate D6 tweaks and DB clenaup¶
If we are using a ‘fresh’ DB copy from D6, we need to do some cleanup
-
mysql
timefields storage. To avoid errors like:Format date plugin could not transform “2020-00-00T00:00:00” using the format “Y-m-d\TH:i:s”. Error: The created date does not match the input value.
We need to change the field instance settings for those fields in Drupal 6, to store month and day, and then… manually assign(
) a month and day to those entries. -
Edit
field_residency_startandfield_residency_endfields, to allow Month and Day storage, under “Granularity: ” field settings. -
Using your preferred method bulk edit date fields corresponding to above fields in the DB (
and) -
Remove
field_eerf_examsandfield_ddown_load_datefrom D6 Member Information CT.
Run Migration¶
drush mim acvo_d6_user_profile --execute-dependenciesdrush mim acvo_d6_field_instance_widget_settings --execute-dependenciesdrush mim acvo_d6_field_formatter_settings --execute-dependenciesdrush mim upgrade_d6_upload_field_instance --execute-dependenciesdrush mim acvo_d6_user_profile --execute-dependencies --update
Tip
Re-import user and --update are needed so the file get’s attached to the entity!
1 2 3 4 5 6 7 8 | <? $raw_date = $object->field_residency_end[0]['value']; $date_split = preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/', $raw_date, $matches); $object->field_residency_end[0]['value'] = $matches[1] . '-01-01T00:00:00'; node_save($object); ?> |