I upgraded a site to D7 and it looks like at least one of the taxonomies didn't convert properly. Anyone know what to do about this stuff in the Taxonomy Upgrade Extras field and how to fix it?

<?php
TO
-220, "TO-220-single gauge (0.020"")", TO-262, Black Anodize, Board Level, Solderable Staked On Tabs
?>

Comments

seanr’s picture

This ended up working for me:

INSERT INTO field_data_taxonomy_vocabulary_1 (entity_type,bundle,deleted,entity_id,revision_id,language,delta,taxonomy_vocabulary_1_tid) SELECT te.* FROM field_data_taxonomyextra te INNER JOIN taxonomy_term_data td ON te.taxonomyextra_tid=td.tid WHERE td.vid=1;
INSERT INTO field_revision_taxonomy_vocabulary_1 (entity_type,bundle,deleted,entity_id,revision_id,language,delta,taxonomy_vocabulary_1_tid) SELECT te.* FROM field_revision_taxonomyextra te INNER JOIN taxonomy_term_data td ON te.taxonomyextra_tid=td.tid WHERE td.vid=1;

DELETE te, tr FROM field_data_taxonomyextra te INNER JOIN field_revision_taxonomyextra tr INNER JOIN taxonomy_term_data td WHERE te.taxonomyextra_tid=td.tid AND tr.taxonomyextra_tid=td.tid AND td.vid=1;

Repeat for each vocabulary.

XerraX’s picture

thanks, this really helped me a lot. little pointer for others trying this: dont forget to empty your cache.

ReAliTy iS JuST a DrEAm. HaCk ThE PLaNet!

stesind’s picture

INSERT INTO field_data_taxonomy_catalog (entity_type,bundle,deleted,entity_id,revision_id,language,delta,taxonomy_vocabulary_1_tid) SELECT te.* FROM field_data_taxonomyextra te INNER JOIN taxonomy_term_data td ON te.taxonomyextra_tid=td.tid WHERE td.vid=1;

INSERT INTO field_revision_taxonomy_catalog (entity_type,bundle,deleted,entity_id,revision_id,language,delta,taxonomy_vocabulary_1_tid) SELECT te.* FROM field_revision_taxonomyextra te INNER JOIN taxonomy_term_data td ON te.taxonomyextra_tid=td.tid WHERE td.vid=1;

DELETE te, tr FROM field_data_taxonomyextra te INNER JOIN field_revision_taxonomyextra tr INNER JOIN taxonomy_term_data td WHERE te.taxonomyextra_tid=td.tid AND tr.taxonomyextra_tid=td.tid AND td.vid=1;

You may have to create the tables before. Just copy from *vocalbulary_1.

afestein’s picture

The first solution posted works for me - thanks.

SheilaRuth’s picture

This was exactly what I needed. Thanks so much!

dman’s picture

Thanks, that seems to help.
However, I have to ensure that the appropriate (taxonomy_term_reference) field definition has been attached to the target content type also, preferably before running this. Must use the expected machine name.

ñull’s picture

Worked here too!

basvredeling’s picture

Thanks for the SQL!
Little sidenote: The `taxonomy_vocabulary_X_tid` is now usually called `taxonomy_vocabulary_X_target_id`.

daniel sanchez’s picture

<?php
INSERT INTO field_data_taxonomy_forums
(entity_type,bundle,deleted,entity_id,revision_id,language,delta,taxonomy_forums_tid) SELECT te.* FROM field_data_taxonomyextra te INNER JOIN taxonomy_term_data td ON te.taxonomyextra_tid=td.tid WHERE td.vid=1;
INSERT INTO field_revision_taxonomy_forums (entity_type,bundle,deleted,entity_id,revision_id,language,delta,taxonomy_forums_tid) SELECT te.* FROM field_revision_taxonomyextra te INNER JOIN taxonomy_term_data td ON te.taxonomyextra_tid=td.tid WHERE td.vid=1;

DELETE te, tr FROM field_data_taxonomyextra te INNER JOIN field_revision_taxonomyextra tr INNER JOIN taxonomy_term_data td WHERE te.taxonomyextra_tid=td.tid AND tr.taxonomyextra_tid=td.tid AND td.vid=1;
?>

The above worked for me to get the forums working again.

msti’s picture

You may also want to use this code to create a field instance for your node

<?php
$voc
= taxonomy_vocabulary_load(28);

 
$instance = array(
   
'field_name' => 'taxonomy_' . $voc->machine_name,
   
'entity_type' => 'node',
   
'label' => 'FIELD LABEL',
   
'bundle' => 'NODE TYPE',
   
'description' => '',
   
'widget' => array(
     
'type' => 'taxonomy_autocomplete',
     
'weight' => -4,
    ),
   
'display' => array(
         
"default" => array(
           
"label" => "above",
           
"type" => "taxonomy_term_reference_plain",
           
"weight" => "28",
           
"settings" => array(
            ),
           
"module" => "taxonomy",
          ),
     
'teaser' => array(
       
'type' => 'taxonomy_term_reference_plain',
       
'weight' => 10,
      ),
    ),
  );
 
field_create_instance($instance);
?>

Drupal developer and consultant
http://www.mikestiv.com