|
@@ -239,9 +239,8 @@ function tripal_library_add_cvterms() {
|
|
|
/**
|
|
|
* This is the required update for tripal_library when upgrading from Drupal core API 6.x.
|
|
|
*
|
|
|
- * @ingroup tripal_library
|
|
|
*/
|
|
|
-function tripal_library_update_7000() {
|
|
|
+function tripal_library_update_7200() {
|
|
|
|
|
|
// the library types were formerly in a vocabulary named 'tripal_library_types'.
|
|
|
// rename that to just be 'library_type'. We cannot use the Tripal API calls
|
|
@@ -312,4 +311,40 @@ function tripal_library_update_7000() {
|
|
|
$error = $e->getMessage();
|
|
|
throw new DrupalUpdateException('Failed to change library_description property type to the library_property CV and update the name: '. $error);
|
|
|
}
|
|
|
+
|
|
|
+ // During the upgrade from D6 to D7 the vocabulary terms assigned to libraries were
|
|
|
+ // copied to the field_data_taxonomyextra table rather than to the correct
|
|
|
+ // field_data_taxonomy_vocabulary_[vid] table. We'll move them.
|
|
|
+ $vid = db_query("SELECT vid FROM {taxonomy_vocabulary} WHERE name = 'Library'")->fetchField();
|
|
|
+ if ($vid) {
|
|
|
+ try {
|
|
|
+ // first move from the field_data_taxonomyextra table
|
|
|
+ $sql = "
|
|
|
+ INSERT INTO {field_data_taxonomy_vocabulary_$vid}
|
|
|
+ (entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomy_vocabulary_" . $vid. "_tid)
|
|
|
+ (SELECT entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomyextra_tid
|
|
|
+ FROM field_data_taxonomyextra
|
|
|
+ WHERE bundle = 'chado_feature')
|
|
|
+ ";
|
|
|
+ db_query($sql);
|
|
|
+ $sql = "DELETE FROM field_data_taxonomyextra WHERE bundle = 'chado_library'";
|
|
|
+ db_query($sql);
|
|
|
+
|
|
|
+ // next move from the field_revision_taxonomyextra table
|
|
|
+ $sql = "
|
|
|
+ INSERT INTO {field_revision_taxonomy_vocabulary_$vid}
|
|
|
+ (entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomy_vocabulary_" . $vid. "_tid)
|
|
|
+ (SELECT entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomyextra_tid
|
|
|
+ FROM field_revision_taxonomyextra
|
|
|
+ WHERE bundle = 'chado_feature')
|
|
|
+ ";
|
|
|
+ db_query($sql);
|
|
|
+ $sql = "DELETE FROM field_revision_taxonomyextra WHERE bundle = 'chado_library'";
|
|
|
+ db_query($sql);
|
|
|
+ }
|
|
|
+ catch (\PDOException $e) {
|
|
|
+ $error = $e->getMessage();
|
|
|
+ throw new DrupalUpdateException('Could not move library taxonomy terms: '. $error);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|