Browse Source

Added support for installing/upgrading to v1.2 of Chado... still needs changes to schema array

spficklin 12 years ago
parent
commit
5f01bf2b84

+ 34 - 14
tripal_core/chado_install.php

@@ -29,9 +29,9 @@ function tripal_core_chado_load_form() {
      '#type' => 'radios',
      '#title' => 'Installation/Upgrade Action',
      '#options' => array(
-        'Chado v1.2' => t('New Install of Chado v1.2 (erases all existing Chado data if Chado already exists)'),
-        'Upgrade v1.11 to v1.2' => t('Upgrade existing Chado v1.11 to v1.2 (no data is lost)'),
-        'Chado v1.11' => t('New Install of Chado v1.11 (erases all existing Chado data if Chado already exists)')
+        'Install Chado v1.2' => t('New Install of Chado v1.2 (erases all existing Chado data if Chado already exists)'),
+        'Upgrade Chado v1.11 to v1.2' => t('Upgrade existing Chado v1.11 to v1.2 (no data is lost)'),
+        'Install Chado v1.11' => t('New Install of Chado v1.11 (erases all existing Chado data if Chado already exists)')
      ),
      '#description' => t('Select an action to perform'),
      '#required' => TRUE
@@ -52,12 +52,12 @@ function tripal_core_chado_load_form() {
  *
  * @ingroup tripal_core
  */
-function tripal_core_chado_v1_11_load_form_submit($form, &$form_state) {
+function tripal_core_chado_load_form_submit($form, &$form_state) {
   global $user;
   $action_to_do   = trim($form_state['values']['action_to_do']);
 
   $args = array($action_to_do);
-  tripal_add_job("Install Chado", 'tripal_core',
+  tripal_add_job($action_to_do, 'tripal_core',
     'tripal_core_install_chado', $args, $user->uid);
 }
 
@@ -66,18 +66,38 @@ function tripal_core_chado_v1_11_load_form_submit($form, &$form_state) {
  *
  * @ingroup tripal_core
  */
-function tripal_core_install_chado() {
-  $schema_file = drupal_get_path('module', 'tripal_core') . '/default_schema.sql';
-  $init_file = drupal_get_path('module', 'tripal_core') . '/initialize.sql';
+function tripal_core_install_chado($action) {
 
-  if (tripal_core_reset_chado_schema()) {
-    tripal_core_install_sql($schema_file);
-    tripal_core_install_sql($init_file);
+  if($action == 'Install Chado v1.2'){
+    $schema_file = drupal_get_path('module', 'tripal_core') . '/chado_schema/default_schema-1.2.sql';
+    $init_file = drupal_get_path('module', 'tripal_core') . '/chado_schema/initialize-1.2.sql';
+    if (tripal_core_reset_chado_schema()) {
+      tripal_core_install_sql($schema_file);
+      tripal_core_install_sql($init_file);
+    }
+    else {
+      print "ERROR: cannot install chado.  Please check database permissions\n";
+      exit;
+    }
   }
-  else {
-    print "ERROR: cannot install chado.  Please check database permissions\n";
-    exit;
+  elseif($action == 'Upgrade Chado v1.11 to v1.2') {
+    $schema_file = drupal_get_path('module', 'tripal_core') . '/chado_schema/default_schema-1.11-1.2-diff.sql';
+    $init_file = drupal_get_path('module', 'tripal_core') . '/chado_schema/initialize-1.11-1.2.sql';
+#    tripal_core_install_sql($schema_file);
+    tripal_core_install_sql($init_file);
   }
+  elseif($action == 'Install Chado v1.11'){
+    $schema_file = drupal_get_path('module', 'tripal_core') . '/chado_schema/default_schema-1.11.sql';
+    $init_file = drupal_get_path('module', 'tripal_core') . '/chado_schema/initialize-1.11.sql';
+    if (tripal_core_reset_chado_schema()) {
+      tripal_core_install_sql($schema_file);
+      tripal_core_install_sql($init_file);
+    }
+    else {
+      print "ERROR: cannot install chado.  Please check database permissions\n";
+      exit;
+    }
+  }  
 }
 
 /**

+ 10 - 0
tripal_core/chado_schema/initialize-1.11-1.2.sql

@@ -0,0 +1,10 @@
+insert into cv (name,definition) values ('chado_properties','Terms that are used in the chadoprop table to describe the state of the database');
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'chado_properties:version');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('version','Chado schema version',(select cv_id from cv where name = 'chado_properties'),(select dbxref_id from dbxref where accession='chado_properties:version'));
+
+INSERT INTO chadoprop (type_id, value) VALUES 
+  ((SELECT cvterm_id 
+   FROM cvterm CVT 
+     INNER JOIN cv CV on CVT.cv_id = CV.cv_id 
+   WHERE CV.name = 'chado_properties' AND CVT.name = 'version'),
+   '1.2')

+ 3 - 1
tripal_core/tripal_core.module

@@ -249,7 +249,9 @@ function tripal_core_job_describe_args($callback, $args) {
     $mview = db_fetch_object(db_query($sql, $args[0]));
     $new_args['View Name'] = $mview->name;
   }
-
+  elseif($callback == 'tripal_core_install_chado'){
+     $new_args['Action'] = $args[0];
+  }
   return $new_args;
 }