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:

  1. 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
  2. Manually create (or export/import from a previously built site) a country field. Field machine name MUST be field_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).

  3. 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.

  4. On the acvo_d6_user_profile migration 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

  1. mysql time fields 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.

  2. Edit field_residency_start and field_residency_end fields, to allow Month and Day storage, under “Granularity: ” field settings.

  3. Using your preferred method bulk edit date fields corresponding to above fields in the DB (and)

  4. Remove field_eerf_exams and field_ddown_load_date from D6 Member Information CT.

Run Migration

  1. drush mim acvo_d6_user_profile --execute-dependencies
  2. drush mim acvo_d6_field_instance_widget_settings --execute-dependencies
  3. drush mim acvo_d6_field_formatter_settings --execute-dependencies
  4. drush mim upgrade_d6_upload_field_instance --execute-dependencies
  5. drush 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);
?>