Change record status: 
Project: 
Introduced in branch: 
8.2.x
Introduced in version: 
8.2.0
Description: 

In the Drupal 7 contrib migrate module, there was a "system-of-record" concept. By default migrating into an existing content item completely replaces it with source data (system-of-record == SOURCE).
In D7, setting the system-of-record to DESTINATION allowed you to selectively import only particular fields from the source, leaving other fields (which may have been manually modified on the destination side) unmolested.

We removed below methods and constants. Since these are never actually used anywhere.

1. getSystemOfRecord() and setSystemOfRecord() from MigrationInterface and Migration.
2. SOURCE and DESTINATION constants from MigrationInterface.
3. protected $systemOfRecord property from Migration.

The closest equivalent in Drupal 8 is the overwrite_properties configuration option on destination plugins. This allows you to specify exactly which properties of the destination object should be overwritten, regardless of what data is available. For example:

destination:
  plugin: 'entity:node'
  overwrite_properties:
    - uid
    - title
    - promoted
Impacts: 
Module developers

Comments

firfin’s picture

Documentation is a bit sparse, " This allows you to specify exactly which properties of the destination object should be overwritten, regardless of what data is available" Does this imply that the other properties are not overwritten?

(not core side question, how does this relate to / work with migrate plus --update flag ? )

andrewmacpherson’s picture

I agree this change record is a bit sparse, so I went digging to see how it worked. You can find out more about the behaviour of the overwrite_properties in the documentation for the EntityContentBase destination class. There's an example migration which demonstrates the overwrite_properties is used.

The behaviour happens in EntityContentBase::updateEntity(), where you'll find this comment:

    // If the migration has specified a list of properties to be overwritten,
    // clone the row with an empty set of destination values, and re-add only
    // the specified properties.

So the default behaviour (when your migration destination does NOT have the overwrite_properties) is to overwrite all the properties when running in update mode.

When the overwrite_properties is present, it is acting as a white-list of properties which will be overwritten. If the field isn't explicitly mentioned here, it is protected from overwrites.

By the way, the update flag IS part of Drupal core migrate API. Contrib just provides the CLI for running migrations.