瀏覽代碼

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

Stephen Ficklin 11 年之前
父節點
當前提交
8533398dca

+ 9 - 6
tripal_contact/tripal_contact.install

@@ -233,15 +233,18 @@ function tripal_contact_update_7000() {
   // add the new contact_relationship_types vocabulary
   // We cannot use the Tripal API calls in the 7000 update 
   // because during upgrade the tripal_core should also be disabled
-  $sql = "INSERT INTO chado.cv (name, definition) VALUES (
-    'contact_relationship_types',
-    'Contains Types of relationships between contacts.')
-  ";
   try {
-    db_query($sql);
+    $check = db_query("SELECT cv_id FROM chado.cv WHERE name = 'contact_relationship_types'")->fetchObject();
+    if (!$check->cv_id) {
+      $sql = "INSERT INTO chado.cv (name, definition) VALUES (
+        'contact_relationship_types',
+        'Contains Types of relationships between contacts.')
+      ";
+      db_query($sql);
+    }
   }
   catch (\PDOException $e) {
     $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to add contact_relationship_types CV: '. $error);
+    throw new DrupalUpdateException('Failed to add contact_relationship_types vocabulary: '. $error);
   }
 }

+ 23 - 14
tripal_library/tripal_library.install

@@ -246,9 +246,12 @@ function tripal_library_update_7000() {
   // 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 
   // because during upgrade the tripal_core should also be disabled
-  $sql = "UPDATE chado.cv SET name = 'library_type' WHERE name = 'tripal_library_types'";
   try {
-    db_query($sql);
+    $check = db_query("SELECT cv_id FROM chado.cv WHERE name = 'library_type'")->fetchObject();
+    if (!$check->cv_id) {
+      $sql = "UPDATE chado.cv SET name = 'library_type' WHERE name = 'tripal_library_types'";
+      db_query($sql);
+    }
   }
   catch (\PDOException $e) {
     $error = $e->getMessage();
@@ -256,29 +259,35 @@ function tripal_library_update_7000() {
   }
   
   // add the library_property CV
-  $sql = "INSERT INTO chado.cv (name, definition) VALUES (
-    'library_property',
-    'Contains properties for libraries.')
-  ";
   try {
-    db_query($sql);
+    $check = db_query("SELECT cv_id FROM chado.cv WHERE name = 'library_property'")->fetchObject();
+    if (!$check->cv_id) {
+      $sql = "INSERT INTO chado.cv (name, definition) VALUES (
+        'library_property',
+        'Contains properties for libraries.')
+      ";
+      db_query($sql);
+    }
   }
   catch (\PDOException $e) {
     $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to add library_property CV: '. $error);
+    throw new DrupalUpdateException('Failed to add library_property vocabulary: '. $error);
   }
   
   // add the library_type CV
-  $sql = "INSERT INTO chado.cv (name, definition) VALUES (
-    'library_type',
-    'Contains terms for types of libraries (e.g. BAC, cDNA, FOSMID, etc).')
-  ";
   try {
-    db_query($sql);
+    $check = db_query("SELECT cv_id FROM chado.cv WHERE name = 'library_type'")->fetchObject();
+    if (!$check->cv_id) {
+      $sql = "INSERT INTO chado.cv (name, definition) VALUES (
+        'library_type',
+        'Contains terms for types of libraries (e.g. BAC, cDNA, FOSMID, etc).')
+      ";  
+      db_query($sql);
+    }
   }
   catch (\PDOException $e) {
     $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to add library_type CV: '. $error);
+    throw new DrupalUpdateException('Failed to add library_type vocabulary: '. $error);
   }
   
   // For Tripal in Drupal 6 the library_description cvterm was stored in the

+ 9 - 6
tripal_organism/tripal_organism.install

@@ -134,15 +134,18 @@ function tripal_organism_update_7000() {
   // add the new organism_property vocabulary
   // We cannot use the Tripal API calls in the 7000 update 
   // because during upgrade the tripal_core should also be disabled
-  $sql = "INSERT INTO chado.cv (name, definition) VALUES (
-    'organism_property',
-    'Contains properties for organisms.')
-  ";
   try {
-    db_query($sql);
+    $check = db_query("SELECT cv_id FROM chado.cv WHERE name = 'organism_property'")->fetchObject();
+    if (!$check->cv_id) {
+      $sql = "INSERT INTO chado.cv (name, definition) VALUES (
+        'organism_property',
+        'Contains properties for organisms.')
+      ";
+      db_query($sql);
+    }
   }
   catch (\PDOException $e) {
     $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to add organism_property CV: '. $error);
+    throw new DrupalUpdateException('Failed to add organism_property vocabulary: '. $error);
   }
 }

+ 8 - 5
tripal_project/tripal_project.install

@@ -134,15 +134,18 @@ function tripal_project_add_cvterms() {
 function tripal_project_update_7000() {
   
   // add the project_property CV
-  $sql = "INSERT INTO chado.cv (name, definition) VALUES (
-    'project_property','Contains properties for projects.')
-  ";
   try {
-    db_query($sql);
+    $check = db_query("SELECT cv_id FROM chado.cv WHERE name = 'project_property'")->fetchObject();
+    if (!$check->cv_id) {
+      $sql = "INSERT INTO chado.cv (name, definition) VALUES (
+        'project_property','Contains properties for projects.')
+      ";
+      db_query($sql);
+    }
   }
   catch (\PDOException $e) {
     $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to add project_property CV: '. $error);
+    throw new DrupalUpdateException('Failed to add project_property vocabulary: '. $error);
   }
 
   // For Tripal in Drupal 6 the project_description cvterm was stored in the

+ 9 - 6
tripal_pub/tripal_pub.install

@@ -250,15 +250,18 @@ function tripal_pub_update_7000() {
   // add the new pub_relationship_types vocabulary
   // We cannot use the Tripal API calls in the 7000 update 
   // because during upgrade the tripal_core should also be disabled
-  $sql = "INSERT INTO chado.cv (name, definition) VALUES (
-    'pub_relationship_types',
-    'Contains Types of relationships between publications.')
-  ";
   try {
-    db_query($sql);
+    $check = db_query("SELECT cv_id FROM chado.cv WHERE name = 'pub_relationship_types'")->fetchObject();
+    if (!$check->cv_id) {
+      $sql = "INSERT INTO chado.cv (name, definition) VALUES (
+        'pub_relationship_types',
+        'Contains Types of relationships between publications.')
+      ";
+      db_query($sql);
+    }
   }
   catch (\PDOException $e) {
     $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to add pub_relationship_types CV: '. $error);
+    throw new DrupalUpdateException('Failed to add pub_relationship_types vocabulary: '. $error);
   }
 }