"Missing migrations upgrade_d7_field_instance" because of duplicate field_name_bundle entries in D7 field_config_instance

Created on 2 September 2022, over 2 years ago
Updated 18 July 2024, 5 months ago

Problem/Motivation

Trying to migrate any migrations that depend on "upgrade_d7_field_instance" will fail if in the original database duplicate combined field_name entries ('entity', 'bundle', 'field_name') exist.

For us, we tried migrating "upgrade_d7_field_instance_widget_settings" after migrating "upgrade_d7_field_instance". The following error appeared, after trying to migrate:

[error] Migration upgrade_d7_field_instance_widget_settings did not meet the requirements. Missing migrations upgrade_d7_field_instance. requirements: upgrade_d7_field_instance.

After a bit of debugging, we found out, that the migration fails inside the health check for upgrade_d7_field_instance inside "Drupal\migrate\Plugin\Migration.php" "allRowsProcessed()". The problem: The source count is higher, then the processed count, thus failing.

// Output: "182|181"
var_dump($source_count . '|' . $processed_count);

After digging inside D7's "field_config_instance" db table and comparing it to the "migrate_map_upgrade_d7_field_instance" migration mapping table, we found a duplicate combined field_name entry ('entity', 'bundle', 'field_name').

After deleting the older entry, the migration worked as expected again.

Drupal 7 allows duplicate combined field_name_bundle entries, because of a faulty index setting:

The "field_name_bundle" key instead should be unique and add the "delete" row to be correct.

Steps to reproduce

Proposed resolution

Throw a more meaningful error like, [error] Migration upgrade_d7_field_instance_widget_settings did not meet the requirements. Migration upgrade_d7_field_instance has duplicate field_name_bundle entries, please delete the duplicate entries or something along those lines.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
MigrationΒ  β†’

Last updated 3 days ago

Created by

πŸ‡©πŸ‡ͺGermany Grevil

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024