Tested against a real-world D6 site with 38 vocabularies and 3774 total terms, some hierarchical.

Settings and vocabularies seem to have migrated fine.

Term migration fails with the following error message:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name'
cannot be null: INSERT INTO {taxonomy_term_data} (tid, vid, uuid,
langcode, name, description__value, description__format, weight,
changed) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1,
:db_insert_placeholder_2, :db_insert_placeholder_3,
:db_insert_placeholder_4, :db_insert_placeholder_5,
:db_insert_placeholder_6, :db_insert_placeholder_7,
:db_insert_placeholder_8); Array
(
    [:db_insert_placeholder_0] => 91
    [:db_insert_placeholder_1] => ad_groups
    [:db_insert_placeholder_2] =>
d5165013-f69b-47fb-a800-ebe3b324ba44
    [:db_insert_placeholder_3] => und
    [:db_insert_placeholder_4] => 
    [:db_insert_placeholder_5] => 
    [:db_insert_placeholder_6] => 
    [:db_insert_placeholder_7] => 0
    [:db_insert_placeholder_8] => 1406812319
)

33 terms seem to have migrated fine, none of them have a parent term.

All terms in the D6 source database have a name value. The term with tid 91 is on the root level of a hierarchical vocabulary and has several child terms. It is not in a vocabulary called 'Ad groups' (which does exist).

In the results of an unordered SELECT * FROM term_hierarchy query to the D6 database 91 is the parent in the first row that has a parent value other than 0.

Comments

aleksip’s picture

Title: d6_taxonomy_term: Integrity constraint violation, 'name' column is null » d6_taxonomy_term: Hierarchical terms
Project: IMP » Drupal core
Version: » 8.0.x-dev
Component: Code » migration system

Investigated this a bit more and it does seem that the error occurs when processing the first term that has a parent term.

A stub row is created for the parent term, but $destination_plugin->import($stub_row) fails.

aleksip’s picture

After further testing with a fresh D6 install it seems that hierarchical term migration goes fine if parent terms have been migrated. But if they are not, migration fails as in the original issue description.

The cause seems to be a missing (dummy) name field value in the stub term entity. I have tried to search for the code where dummy field values are set, similar to createStub in D7 migrate, but haven’t been successful so far.

aleksip’s picture

StatusFileSize
new1.11 KB

Here is a patch to MigrateTaxonomyTermTest that should show the bug.

benjy’s picture

Category: Support request » Bug report
Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 3: 2313241-3.patch, failed testing.

aleksip’s picture

StatusFileSize
new2.34 KB

Here is a patch containing a fix as instructed by chx (a new EntityTaxonomyTerm class) and the modifications to MigrateTaxonomyTermTest in #3.

With this patch applied the original real-world migration test mentioned in the issue description completed successfully.

benjy’s picture

Status: Needs work » Needs review

Good work, set to "Needs review" so the bot can run the test suite.

dawehner’s picture

Status: Needs review » Needs work

The patch fixes the problem for me nicely! Great work!! Using a stub entry until the migration ran over the corresponding taxonomy term is a great idea!

+++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityTaxonomyTerm.php
@@ -0,0 +1,34 @@
+use Drupal\Core\Entity\EntityManagerInterface;
+use Drupal\Core\Entity\EntityStorageInterface;
+use Drupal\Core\State\StateInterface;
+use Drupal\migrate\Entity\MigrationInterface;
+use Drupal\migrate\Plugin\MigratePluginManager;
...
+use Symfony\Component\DependencyInjection\ContainerInterface;

Note: Just this single class is neeed, all other use statements can be removed.

benjy’s picture

Status: Needs work » Needs review
StatusFileSize
new2.06 KB
new1.24 KB

Removed use statements plus a few other minor changes.

penyaskito’s picture

Title: d6_taxonomy_term: Hierarchical terms » d6_taxonomy_term migrate fails when the parent term has not been already migrated
Status: Needs review » Reviewed & tested by the community

Patch tests this casuistic, and #8 has been cleaned up. So RTBC.
Updated issue title.

+++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityTaxonomyTerm.php
@@ -0,0 +1,29 @@
+ *   id = "entity:taxonomy_term"

We only need to specify a class with a plugin id and it overrides entity:*? I <3 this feature.

dawehner’s picture

Yeah, indeed, this is really cool.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for testing the migrate path for D8!

Committed and pushed to 8.x. Thanks!

  • webchick committed 8d18470 on 8.0.x
    Issue #2313241 by aleksip, benjy: Fixed d6_taxonomy_term migrate fails...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

swathikris’s picture

Tested against a real-world D6 site - 31 vocabularies ~4500 terms and some hierarchical with multiple parents
Get the same Integrity constraint violation, when it comes to migrating terms with multiple parents.
eg: in d6 term_hierarchy
|tid|parent|
|13|0|
|14|13|
|15|13|
|16|0|
|17|13|
|18|13|
|19|17|
|19|20|
|20|13|

bkeller’s picture

Preparing for a D6 to D8 migration and while the migration completes, taxonomy terms are not fully migrated. Vocabularies are migrated, and then a few (7) terms succeed before returning the following error:

Running d6_taxonomy_term ok
SQLSTATE23000: Integrity constraint violation: 1048 Column 'name' cannot be null: INSERT INTO {taxonomy_term_field_data} (tid, vid, langcode, name, description__value, description__format, weight, error
changed, default_langcode) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5,
:db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8); Array
(
:db_insert_placeholder_0 => 443
:db_insert_placeholder_1 => author
:db_insert_placeholder_2 => en
:db_insert_placeholder_3 =>
:db_insert_placeholder_4 =>
:db_insert_placeholder_5 =>
:db_insert_placeholder_6 => 0
:db_insert_placeholder_7 => 1431101967
:db_insert_placeholder_8 => 1
)

I thought it might be a data issue, since this was marked as fixed in the latest release. I found one term missing a name, but it was not related to the above error, and deleting it from the DB had no affect.
Just to see what would happen, I modified the database tables to allow for NULL values:

ALTER TABLE taxonomy_term_data CHANGE vid vid varchar(32) DEFAULT NULL;
ALTER TABLE taxonomy_term_field_data CHANGE name name varchar(255) DEFAULT NULL;
ALTER TABLE taxonomy_term_field_data CHANGE vid vid varchar(32) DEFAULT NULL;
ALTER TABLE taxonomy_term_field_data CHANGE weight weight int(11) DEFAULT NULL;

At which point the taxonomy terms did migrate, the content types had the appropriate taxonomy term fields, but no taxonomy terms were applied to any content. I also received the following error:

Failed to lookup array (                                                                                                                                                                                              [error]
  0 => 'text',
  1 => 'hidden',
) in the static map.

This site has 5700+ nodes, 6 vocabularies, and 490 terms in term_data. I've posted in this issue because it seems to be the same problem, but will start a new bug report if needed.

scotwith1t’s picture

Status: Closed (fixed) » Needs work

Looks like this needs to be re-rolled against the current dev? /core/modules/migrate_drupal/src/Tests/Dump/Drupal6TaxonomyTerm.php doesn't exist in the current version, so this patch does not apply...

bkeller’s picture

Status: Needs work » Closed (fixed)

It looks as though my above issue was related to using the beta10 version rather than pulling the current dev version from git.
After rebuilding and re-running a migrate with the current dev version I no longer get this error, and taxonomy terms do migrate.
There are other issues, but we'll post those in the appropriate threads.
Sorry for the confusion.

drupali’s picture

Migration (Drupal 6 to Drupal-8.1.7) does not bring any taxonomy terms and content taxonomy fields. I get the error
Failed to lookup field type array ( 0 => 'content_taxonomy', 1 => 'default', ) in the static map.
Any help would be highly appreciated !