Browse Source

Fixed bug in preparing Chado after upgrade from Tv2

Stephen Ficklin 9 years ago
parent
commit
2777c76efa
2 changed files with 37 additions and 3 deletions
  1. 5 1
      README.txt
  2. 32 2
      tripal_chado/tripal_chado.install

+ 5 - 1
README.txt

@@ -50,9 +50,13 @@ Step 3: Enable the tripal module
 
   drush pm-enable tripal
  
-Step 4:  
+Step 4: Enable the tripal_chado module  
 
   drush pm-enable tripal_chado
+  
+Step 5:  Apply updates
+
+  drush updatedb
 
 Note: Use of deprecated API functions from Tripal v1 will cause a template
 to not work because Tripal v1 deprecated API fucntions have been removed

+ 32 - 2
tripal_chado/tripal_chado.install

@@ -499,5 +499,35 @@ function tripal_chado_chado_entity_schema() {
  * Moves vocabulary terms from the 'tripal' vocabulary to the 'local' vocabulary.
  */
 function tripal_chado_update_7300() {
-  // Move all terms in the 'tripal' cv' over to 'local'.
-}
+  try {
+
+    tripal_insert_db(array(
+      'name' => 'local',
+      'description' => variable_get('site_name', 'This site.'),
+    ));
+
+    // Move the library properties out of the tripal database and into the
+    // local database.
+    $sql = "
+      UPDATE {dbxref}
+        SET db_id = (SELECT db_id FROM {db} WHERE name = 'local')
+      WHERE dbxref_id IN (
+        SELECT DISTINCT CVT.dbxref_id
+        FROM {cvterm} CVT
+          INNER JOIN {cv} CV ON CV.cv_id = CVT.cv_id
+        WHERE CV.name IN (
+          'library_property',
+          'library_type',
+          'project_property',
+          'nd_experiment_types',
+          'nd_geolocation_property',
+          'tripal_analysis'
+        )
+      )
+    ";
+    chado_query($sql);
+  }
+  catch (\PDOException $e) {
+    $error = $e->getMessage();
+    throw new DrupalUpdateException('Failed to complete update' . $error);
+  }}