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?

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`.

parth vora’s picture

Hello @seanr,

First of all thanks for the answer. However I have some questions. I have upgrade D6 to D7 by following exact steps written into upgrade.txt. In D6, there was a content type with 5 various vocabularies assigned to it. But after upgradation to D7, it shows a single field called "Taxonomy upgrade extras" in node add & edit form of that content type. And that field is an auto-complete text box.
On field setting page of that field, it shows all the vocabularies instead of those just 5 assigned vocabularies.

So what I want to to get is 5 various select boxes for those 5 vocabularies on node add/edit page. I guess for that I need to create 5 term reference fields into the content type. And I'm also confused with above queries as with new fields there will be new tables in db.

So can you please assist me with that?

Any help would be appreciated.

Thanks,
Parth Vora

daniel sanchez’s picture

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


$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