Drupal 7 to 11 migration: taxonomy term hierarchy not preserved if parent tid > child tid

Created on 18 June 2025, about 2 months ago

Problem/Motivation

When migrating taxonomy terms from Drupal 7 to Drupal 11, if the Drupal 7 database has hierarchical terms where the parent term's tid is greater than the child term's tid, the parent-child relationship is not preserved in the migration. In the migrated Drupal 11 site, the child term winds up at the top level (no parent).

Steps to reproduce

  • Create a Drupal 7 site with some taxonomy terms.
  • Create at least one term that becomes the parent of one or more terms that were previously created.
  • Set up a Drupal 11 site that references the Drupal 7 database for migration.
  • drush migrate-import d7_taxonomy_term:[vocabulary] (where [vocabulary] is the vocabulary used when you created the terms)

Proposed resolution

I realize this is related to other issues where migration_lookup is unable to create stubs under certain circumstances, and this is one of those circumstances. However, an easy fix for this particular instance is to change the migrate source to take the taxonomy_term_hierarchy parent_id into account, and order the taxonomy terms by parent id and then tid. This ensures any parent term will be migrated before their children.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component

migration system

Created by

πŸ‡ΊπŸ‡ΈUnited States paulmckibben Atlanta, GA

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024