I'm a little bit new in Drupal but experienced in PHP. I would like to migrate data from CSV and assign to existing nodes in DB.

My question is about the possibility to match processing rows with existing data from the database.
I mean, I have CSV file with data and with foreign key called: SERVICE_ACTION and now I would like to assign that data to existing NODE which hasn’t SERVICE_ACTION key but has different KEY which is assigned to another specific entity with Service Action key. How can I get ID of that entity in migration script to assign?

Perhaps, I need target_id to assign newly created paragraph to the specific node. I’m not sure what I’m working bad.

langcode: en
status: true
      - xxx_migration
      - paragraphs
id: xxx_release_notes
  - custom-migrate
  - soap-apis
migration_group: xxx_soap_api
label: 'xxx release notes'
  plugin: csv
  data_fetcher_plugin: file
  path: modules/custom/xxx_migration/artifacts/releases_notes.csv
  header_row_count: 1
    - id
      id: 'Unique Id'
      title: Title
      body: 'Post body'
      service_action_code: 'Service Action Code'
    plugin: default_value
    default_value: people
    plugin: migration_lookup
    migration: xxx_release_notes
    source: service_action_code
  plugin: 'entity_reference_revisions:paragraph'
  default_bundle: release_note
  required: {  }
optional: {  }

here is my CSV file:

1,TITLE,example body,PassengerDetailsRQ
2,TITLE2,example body2,ePaymentRQ
  • I don't know if it's possible to query the database from that. Maybe with something like a callback if that's possible? I'd to that myself taking github.com/GiantRobot/csvimport as a starting point.
    – leymannx
    Commented Feb 15, 2019 at 14:39
  • AFAIK the migrate module can not update entities it has not created itself. You'll have to create your own module/code, I don't think the Migrate module fits your use case.
    – Hudri
    Commented Feb 15, 2019 at 18:43
  • So you're wanting to look up a node entity id reference for field_service_action_code using the value service_action_code via a field value on the referenced node?
    – Shawn Conn
    Commented Feb 16, 2019 at 20:54

1 Answer 1


I don't know the exact answer. But maybe this information can get you on the right track. First the migration process has the ability to update earlier migrated entities, it does this with the help of high-water-marks and timestamps (see Drupal's documentation). Maybe you can do a trick to use this feature. Furthermore there is a lot of good documentation about the migration-process, I recommend this site, an extensive tutorial about the process in 31(!) steps/days, https://understanddrupal.com/31-days-of-migrations or https://www.phase2technology.com/blog/migration-making-it-all-work. Behind it some of the "Drupalstars" from the migration and comprehensibly written. Hope you find your answer there.

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.