Migrating Into Existing Nodes in Drupal 8, Including Rollback Missing from Source
Please read this entire post (including the disclaimer at the bottom) before you put any of it to use.
The site I’m basing this off had an existing set of nodes and a new migration that had the same nodes (and many more) in the data source. I wanted to map the existing nodes to their migration-based counterparts and treat every node as if it originated from the migration.
As of today, using a few patches makes it easy (thanks contributors!) to rollback items that no longer exist in a D8 migration’s source data. See Migrate support for deleting items no longer in the incoming data and Implement rollback of items no longer in source data
With these patches you can import and rollback in two commands:PHP12drush mi mymigration_name_here --updatedrush migrate-rollback --missing-from-source mymigration_name_here
What if the data that you’re migrating (and rolling back if removed) already existed in Drupal before you started using the migration? If you attempt to migrate content, then rollback removed items, you will find that the items that no longer exist in the source will not be deleted if they existed before the migration.
First, I should describe how I’m pulling data into existing nodes.
This is as simple as populating the node ID in the process section of your migration YML, like this: