Document ID constraints

Created on 13 February 2024, 9 months ago

Problem/Motivation

When you declare a nid for some, but not all, nodes in a node migration you will get an integrity constraint violation error when running a migration update similar to:

 [error]  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '71e6dcb6-3c60-4145-9df1-9b50acc3d081' for key 'node_field__uuid__value': INSERT INTO "node" ("vid", "type", "uuid", "langcode") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array
(
    [:db_insert_placeholder_0] => 
    [:db_insert_placeholder_1] => creature
    [:db_insert_placeholder_2] => 71e6dcb6-3c60-4145-9df1-9b50acc3d081
    [:db_insert_placeholder_3] => en
)
 (/var/www/html/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:817) 

This is the case for any other id as well (taxonomy terms, users, etc.).

Steps to reproduce

  1. Create a node migration with multiple nodes
  2. Give 1 node a nid and do not give the others one
  3. Import the nodes (drush mim mdc_node_[whatever you called it])
  4. Run a migration update (drush mim mdc_node_[whatever you called it] --update)

Proposed resolution

I don't believe this has anything to do with migrate_default_content itself, but we should document the fact that if you're going to be adding IDs into your migrations, you need to make sure all entities being migrated have IDs.

📌 Task
Status

Active

Version

2.0

Component

Documentation

Created by

🇨🇦Canada nickdjm

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024