Score:0

How can I prevent my migration from overwriting existing nodes instead of using the source's (D7) NID

ng flag

I have imported my content types from D7 to D9 using /upgrade for the complete migration and the data is all good. I then have a separate migration to import and convert my date fields and this works too, except that it overwrites all of the existing nodes instead of using their exiting NID or pulling it from the source again. Any ideas how to prevent this?

id: event_node
label: Event Nodes
migration_group: custom
source:
  plugin: d7_node
  target: event
destination:
  plugin: entity:node
  bundle: event
process:
  nid: nid
  type:
    plugin: default_value
    default_value: event
  field_event_date:
    -
      plugin: sub_process
      source: field_event_date
      process:
        value:
          -
            plugin: format_date
            from_format: 'Y-m-d H:i:s'
            to_format: 'Y-m-d\TH:i:s'
            source: value

        end_value:
          -
            plugin: format_date
            from_format: 'Y-m-d H:i:s'
            to_format: 'Y-m-d\TH:i:s'
            source: value2
        timezone:
          -
            plugin: default_value
            default_value: 'America/New_York'
        rrule:
          -
            plugin: get
            source: rrule
miststudent2011 avatar
fr flag
Seems you are doing something wrong. Ping me on Drupal slack will try to help you
miststudent2011 avatar
fr flag
Remove all other fields except nid and date fields. It will map data to only those two fields leaving other fields untouched.
quantumized avatar
ng flag
When I removed the other fields, specifically the "type" filed the imported runs but the date fields are not updated.
miststudent2011 avatar
fr flag
In source change target key to node_type. It will solve your issue
miststudent2011 avatar
fr flag
Don't forget to reimport the config
miststudent2011 avatar
fr flag
Check this file for reference https://drupal.slack.com/files/UBUGWVA3G/F02J5A3PZV3/d7_node_article_part_one.yml
quantumized avatar
ng flag
Thank you for the tip but the target key is already set to the node type's machine name ("event"). And the plugin is d7:node - per your tip there is nothing for me to change.
miststudent2011 avatar
fr flag
No no, what i meant is remove the key target completely and add a new key node_type: event and try again
quantumized avatar
ng flag
Thank you. I had actually realized that after posting. So the only thing under "Souce" is "node_type: event" but now I'm getting the error: "The "" plugin does not exist." - I looked at your example to compare but don't see the issue. I'll update my current YML in the original post.
miststudent2011 avatar
fr flag
Do one thing remove every thing from your yml and copy my yml to your yml and change names accordingly. And keep nid and add date field and try to import. It will work
miststudent2011 avatar
fr flag
plugin: d7_node is needed dont delete it
quantumized avatar
ng flag
Ugg, I tried your template but I think it's just too different of a scenario. I went back to my basic config and noticed that id specify the nid when running migrate-import that it updates the node correct but if I run it without so it just processes all of the event nodes then it resets their nids starting at nid 1. This works for a single specified NID: drush migrate-import event_node --update --idlist=5318
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.