Migrate Content With Sequential IDs

When migrations are generated with Migrate Upgrade, nodes and revisions are imported with their preexisting IDs.

ID Conflicts

A common issue with migrations is when content is created in development, they may collide with imported IDs. If the migration is run once at the start of development and content is added afterwards, then there are no issues. However, if content updates are needed from the old site before launch they will collide.

More info about ID conflicts

Aliases

Note that if content was accessed at node/* urls and the ID changes, it will mess up the site's SEO for any links pointing to the old ID. If the site was using aliases for all it's content, and the aliases are imported, this is not an issue. In some rare cases a link could have still used a node ID, like if pathauto was enabled after some content was already created. If the old site used pathauto consistently, and the same pattern is configured on the new site, aliases may not need to be migrated, but make sure there aren't manually added ones.

Migration config

id: upgrade_d7_node_complete_page
class: Drupal\node\Plugin\migrate\D7NodeTranslation
label: 'Node complete (Page)'
source:
  plugin: d7_node_complete
  node_type: page
process:
  nid:
    -
      plugin: get
      source: tnid
  vid:
    -
      plugin: get
      source: vid
  langcode:
    -
      plugin: default_value
      source: language
      default_value: und
...

See this article for details on the NodeComplete (source) and D7NodeTranslation (migration) plugins used here.

Migration Lookups

Any field or property that referenced an entity needs to use the migrate_lookup process plugin to get the right ID.

Author

uid:
  -
    plugin: migration_lookup
    migration: upgrade_d7_user
    source: node_uid
...
revision_uid:
  -
    plugin: migration_lookup
    migration: upgrade_d7_user
    source: revision_uid

Taxonomy

field_topic:
  -
    plugin: sub_process
    source: field_topic
    process:
      target_id:
        -
          plugin: migration_lookup
          migration: upgrade_d7_taxonomy_term_topics
          source: tid

Content

field_article_ref:
  -
    plugin: sub_process
    source: field_article_ref
    process:
      target_id:
        -
          plugin: migration_lookup
          migration: upgrade_d7_node_article
          source: target_id

Single value references can be shortened to:

field_article_ref:
  plugin: migration_lookup
  migration: upgrade_d7_node_article
  source: field_article_ref/0/target_id
Tags
Migration
Modules