Taxonomy term migration

Created on 6 August 2020, almost 4 years ago
Updated 14 March 2023, over 1 year ago

Problem/Motivation

I'm working on the migration D7 site to D9 with all content and functionality. During the tasks of vocabularies and terms migration I found a strange bug - "No data found" and MySql errors when I'm trying to check migration status via drush or UI.
MySQL error example for "main_term" vocabulary terms migration:

SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'machine_name': SELECT COUNT(*) AS "expression"
FROM
(SELECT DISTINCT td.*, "tv"."machine_name" AS "machine_name", 1 AS "expression"
FROM
{taxonomy_term_data} "td"
LEFT OUTER JOIN {taxonomy_vocabulary} "tv" ON td.vid = tv.vid
WHERE "tv"."machine_name" IN (:db_condition_placeholder_0)) "subquery"; Array
(
[:db_condition_placeholder_0] => main_term
)

And the reason is - on D7 site installed and used https://www.drupal.org/project/taxonomy_machine_name β†’ module that added machine_name field to taxonomy_term_data D7 table. And MySQL can't execute queries to get data with the same row names (machine_name from taxonomy_term_data and machine_name from taxonomy_vocabulary).

Steps to reproduce

Just use core migration from D7 with installed taxonomy_machine_name module

Proposed resolution

In d7_taxonomy_term migration plugin define exact fields from source table instead of "td.*".
core/modules/taxonomy/src/Plugin/migrate/source/d7/Term.php

public function query() {
  $query = $this->select('taxonomy_term_data', 'td')
    // ->fields('td')
    ->fields('td', ['tid', 'vid', 'name', 'description', 'format', 'weight'])

Another solution - describe somewhere in the migration documentation "If you are using taxonomy_machine_name D7 module - before the migration you need to rename machine_name field in taxonomy_term_data table."

One more solution - ask taxonomy_machine_name maintainer to rename machine_name field in taxonomy_term_data table and include push users to update the module before upgrading Drupal.

πŸ› Bug report
Status

Closed: duplicate

Version

9.0

Component
MigrationΒ  β†’

Last updated about 7 hours ago

Created by

πŸ‡ΊπŸ‡¦Ukraine geophysicist

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.69.0 2024