Explorar el Código

Fixed upgrade functions to not use Tripal API as all modules must be disabled for D7 upgrade including tripal_core

Stephen Ficklin hace 11 años
padre
commit
b616ce8623

+ 6 - 3
tripal_contact/tripal_contact.install

@@ -237,8 +237,11 @@ function tripal_contact_update_7000() {
     'contact_relationship_types',
     'Contains Types of relationships between contacts.')
   ";
-  $success = db_query($sql);
-  if (!$success) {
-    throw new DrupalUpdateException('Failed to add contact_relationship_types CV');
+  try {
+    db_query($sql);
+  }
+  catch (\PDOException $e) {
+    $error = $e->getMessage();
+    throw new DrupalUpdateException('Failed to add contact_relationship_types CV: '. $error);
   }
 }

+ 24 - 12
tripal_library/tripal_library.install

@@ -247,9 +247,12 @@ function tripal_library_update_7000() {
   // rename that to just be 'library_type'. We cannot use the Tripal API calls 
   // because during upgrade the tripal_core should also be disabled
   $sql = "UPDATE chado.cv SET name = 'library_type' WHERE name = 'tripal_library_types'";
-  $success = db_query($sql);
-  if (!$success) {
-    throw new DrupalUpdateException('Failed to rename tripal_library_types CV.');
+  try {
+    db_query($sql);
+  }
+  catch (\PDOException $e) {
+    $error = $e->getMessage();
+    throw new DrupalUpdateException('Failed to change the vocabulary from tripal_library_types to library_type: '. $error);
   }
   
   // add the library_property CV
@@ -257,9 +260,12 @@ function tripal_library_update_7000() {
     'library_property',
     'Contains properties for libraries.')
   ";
-  $success = db_query($sql);
-  if (!$success) {
-    throw new DrupalUpdateException('Failed to add library_property CV');
+  try {
+    db_query($sql);
+  }
+  catch (\PDOException $e) {
+    $error = $e->getMessage();
+    throw new DrupalUpdateException('Failed to add library_property CV: '. $error);
   }
   
   // add the library_type CV
@@ -267,9 +273,12 @@ function tripal_library_update_7000() {
     'library_type',
     'Contains terms for types of libraries (e.g. BAC, cDNA, FOSMID, etc).')
   ";
-  $success = db_query($sql);
-  if (!$success) {
-    throw new DrupalUpdateException('Failed to add library_type CV');
+  try {
+    db_query($sql);
+  }
+  catch (\PDOException $e) {
+    $error = $e->getMessage();
+    throw new DrupalUpdateException('Failed to add library_type CV: '. $error);
   }
   
   // For Tripal in Drupal 6 the library_description cvterm was stored in the
@@ -287,8 +296,11 @@ function tripal_library_update_7000() {
       name = 'library_description' AND
       cv_id = (SELECT cv_id FROM chado.cv WHERE name = 'tripal')
   ";
-  $success = db_query($sql); 
-  if (!$success) {
-    throw new DrupalUpdateException('Failed to move library properties to new library_property CV.');
+  try {
+    db_query($sql);
+  }
+  catch (\PDOException $e) {
+    $error = $e->getMessage();
+    throw new DrupalUpdateException('Failed to change library_description property type to the library_property CV and update the name: '. $error);
   }
 }

+ 6 - 3
tripal_organism/tripal_organism.install

@@ -138,8 +138,11 @@ function tripal_organism_update_7000() {
     'organism_property',
     'Contains properties for organisms.')
   ";
-  $success = db_query($sql);
-  if (!$success) {
-    throw new DrupalUpdateException('Failed to add organism_property CV');
+  try {
+    db_query($sql);
+  }
+  catch (\PDOException $e) {
+    $error = $e->getMessage();
+    throw new DrupalUpdateException('Failed to add organism_property CV: '. $error);
   }
 }

+ 6 - 3
tripal_project/tripal_project.install

@@ -148,8 +148,11 @@ function tripal_project_update_7000() {
       name = 'project_description' AND
       cv_id = (SELECT cv_id FROM chado.cv WHERE name = 'tripal')
   ";
-  $success = db_query($sql);
-  if (!$success) {
-    throw new DrupalUpdateException('Failed to move project properties to new project_property CV.');
+  try {
+    db_query($sql);
+  }
+  catch (\PDOException $e) {
+    $error = $e->getMessage();
+    throw new DrupalUpdateException('Failed to change project_description property type to the project_property CV and update the name: '. $error);
   }
 }

+ 6 - 3
tripal_pub/tripal_pub.install

@@ -254,8 +254,11 @@ function tripal_pub_update_7000() {
     'pub_relationship_types',
     'Contains Types of relationships between publications.')
   ";
-  $success = db_query($sql);
-  if (!$success) {
-    throw new DrupalUpdateException('Failed to add pub_relationship_types CV');
+  try {
+    db_query($sql);
+  }
+  catch (\PDOException $e) {
+    $error = $e->getMessage();
+    throw new DrupalUpdateException('Failed to add pub_relationship_types CV: '. $error);
   }
 }