0

In a custom module (assoc), I have a custom Content Entity (Person) with these fields:

$fields['lastname'] = BaseFieldDefinition::create('string')
$fields['firstname'] = BaseFieldDefinition::create('string')
$fields['email'] = BaseFieldDefinition::create('email')
$fields['cellphone'] = BaseFieldDefinition::create('telephone')

I migrated Person content from a Drupal 6 site using Migrate Source CSV, Migrate Plus, Migrate Tools and this migration file:

id: migration_persons
migration_tags: null
migration_group: null
label: 'Person migration from CSV'
source:
  plugin: csv
  path: /Users/efalzon/Sites/JdP8M7b/config/migration_Persons.csv
  delimiter: ';'
  enclosure: '"'
  header_row_count: 1
  keys:
    - id
process:
  id: id
  lastname: lastname
  firstname: firstname
  cellphone: cellphone
  email: mail
  iscontact: iscontact
  isactive: isactive
  member_id: member_id
  user_id: user_id
  owner_id:
    plugin: default_value
    default_value: 1
destination:
  plugin: 'entity:person'
migration_dependencies:
  required: {}
  optional: {}

I added a field to this entity using the UI: enter image description here The corresponding config files are field.storage.person.field_sel_initial_credit.yml and field.field.person.person.field_sel_initial_credit.yml I tried to migrate some content to this field using

id: migration_sel_initial_credit
migration_tags: null
migration_group: null
label: 'Sel initial credit migration from CSV'
source:
  plugin: csv
  path: /Users/efalzon/Sites/JdP8M7b/config/migration_Sel_initial_credit.csv
  delimiter: ';'
  enclosure: '"'
  header_row_count: 1
  keys:
    - uid
process:
  bundle: "person"
  entity_id: uid
  revision_id: uid
  field_sel_initial_credit_value: value
destination:
  plugin: 'entity:field_storage_config'
migration_dependencies:
  required: {}
  optional: {}

and I got this error when executing the migration:

[error]  Attempt to create a field storage without a field name. (/Users/efalzon/Sites/JdP8M7b/web/core/modules/field/src/Entity/FieldStorageConfig.php:252)

What am i missing?

  • The error comes from destination: plugin: 'entity:field_storage_config', which should most likely be destination: plugin: 'entity:person'. BUT: Migration a very strict 1 source:1 target entity mapping, you can't update a single field this way. Read the docs for the migration_lookup process plugin. – Hudri Jul 2 '19 at 14:42
  • I did (read the docs about migration_lookup) and didn't find any clue on how to solve my problem. Any idea to put me on the track? – gbmapo Jul 3 '19 at 12:52
  • More generally, is there a way to modify the first migration file (the one that migrates Persons) to migrate field_sel_initial_credit_value at the same time? – gbmapo Jul 3 '19 at 12:54
0

In fact, it was easier than I thought. I just had to add the field to the Person migration file:

id: migration_persons_with_sel
migration_tags: null
migration_group: null
label: 'Person migration from CSV'
source:
  plugin: csv
  path: /Users/efalzon/Sites/JdP8M7b/config/migration_Persons.csv
  delimiter: ;
  enclosure: '"'
  header_row_count: 1
  keys:
    - id
process:
  id: id
  lastname: lastname
  firstname: firstname
  cellphone: cellphone
  email: mail
  iscontact: iscontact
  isactive: isactive
  member_id: member_id
  user_id: user_id
  field_sel_initial_credit: credit <----------
  owner_id:
    plugin: default_value
    default_value: 1
destination:
  plugin: 'entity:person'
migration_dependencies:
  required: {  }
  optional: {  }
| improve this answer | |
  • Yes, fields are not destinations. – Kevin Aug 27 '19 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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