Преглед на файлове

Debugging tables being created in wrong schema

spficklin преди 12 години
родител
ревизия
a5d4d5e7dd

+ 2 - 5
tripal_analysis/tripal_analysis.install

@@ -18,7 +18,6 @@ function tripal_analysis_install() {
   // Create analysisfeatureprop table in chado. This cannot be accomplished
   // by calling drupal_install_schema because it's not in the drupal db. This
   // table is used to store Blast xml and Interpro html/goterms
-  $previous_db = tripal_db_set_active('chado');
   if (!db_table_exists('analysisfeatureprop')) {
     $sql = "CREATE TABLE analysisfeatureprop (".
             "  analysisfeatureprop_id SERIAL PRIMARY KEY, ".
@@ -28,9 +27,8 @@ function tripal_analysis_install() {
             "  rank INTEGER NOT NULL, ".
             "  CONSTRAINT analysisfeature_id_type_id_rank UNIQUE(analysisfeature_id, type_id, rank)".
             ")";
-    db_query($sql);
+    chado_query($sql);
   }
-  tripal_db_set_active($previous_db);
 
   tripal_cv_add_cvterm(array('name' => 'analysis_type', 'def' => 'The type of analysis was performed. This value is automatically set by each Tripal Analysis module and should be equal to the module name (e.g. tripal_analysis_blast, tripal_analysis_go).'), 'tripal', 0, 1, 'tripal');
   tripal_cv_add_cvterm(array('name' => 'analysis_date', 'def' => 'The date that an analysis was performed.'), 'tripal', 0, 1, 'tripal');
@@ -134,8 +132,7 @@ function tripal_analysis_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    $version = tripal_core_set_chado_version();
-    if ($version == 'not installed') {
+    if (!tripal_core_is_chado_installed()) {
       $requirements ['tripal_analysis'] = array(
             'title' => "tripal_analysis",
             'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 1 - 2
tripal_bulk_loader/tripal_bulk_loader.install

@@ -221,8 +221,7 @@ function tripal_bulk_loader_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    $version = tripal_core_set_chado_version();
-    if ($version == 'not installed') {
+    if (!tripal_core_is_chado_installed()) {
       $requirements ['tripal_bulk_loader'] = array(
             'title' => "tripal_bulk_loader",
             'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 23 - 0
tripal_core/api/tripal_core.api.inc

@@ -3165,3 +3165,26 @@ function tripal_core_clean_orphaned_nodes($table, $job_id) {
 
   return '';
 }
+
+/**
+ * Check whether chado is installed (either in the same or a different database)
+ *
+ * @return
+ *   TRUE/FALSE depending upon whether chado is installed.
+ *
+ * @ingroup tripal_chado_api
+ */
+function tripal_core_is_chado_installed() {
+  global $db_url, $db_type;
+
+  // first check if chado is in the db_url of the
+  // settings.php file
+  if (is_array($db_url)) {
+    if (isset($db_url['chado'])) {
+      return TRUE;
+    }
+  }
+
+  // check to make sure the chado schema exists
+  return tripal_core_chado_schema_exists();
+}

+ 9 - 44
tripal_core/tripal_core.module

@@ -25,36 +25,25 @@ require_once "api/tripal_core.api.inc";
 function tripal_core_init() {
   global $base_url;
   
-  // the two lines below are necessary to ensure that the search_path
-  // variable is always set.  In the case where a view needs to query the
-  // chado schema when it is local to the Drupal database.  Otherwise the
-  // search_path isn't set.  When tripal_db_set_active is called it
-  // automatically sets the search path if chado is local to the
-  // Drupal database
-//  $previous = tripal_db_set_active('chado');
-//  tripal_db_set_active($previous);
-//  tripal_db_set_chado_search_path('chado');
- 
-
   // create the 'tripal' controlled volcabulary in chado but only if it doesn't already exist, and
   // only if the chado database is present.
   if (tripal_core_is_chado_installed()) {
-    $previous_db = tripal_db_set_active('chado');  // use chado database
-    if (!db_fetch_object(db_query("SELECT * FROM {cv} WHERE name = 'tripal'"))) {
-      $results = db_query("INSERT INTO {cv} (name,definition) ".
-                         "VALUES ('tripal', 'Terms used by Tripal for modules to manage data such as that stored in property tables like featureprop, analysisprop, etc')");
+    if (!db_fetch_object(chado_query("SELECT * FROM {cv} WHERE name = 'tripal'"))) {
+      $results = chado_query(
+        "INSERT INTO {cv} (name,definition) ".
+        "VALUES ('tripal', 'Terms used by Tripal for modules to manage data such as that stored in property tables like featureprop, analysisprop, etc')");
     }
-    if (!db_fetch_object(db_query("SELECT * FROM {db} WHERE name = 'tripal'"))) {
-      $results = db_query("INSERT INTO {db} (name,description) ".
-                          "VALUES ('tripal', 'Used as a database placeholder for tripal defined objects such as tripal cvterms')");
+    if (!db_fetch_object(chado_query("SELECT * FROM {db} WHERE name = 'tripal'"))) {
+      $results = chado_query(
+        "INSERT INTO {db} (name,description) ".
+        "VALUES ('tripal', 'Used as a database placeholder for tripal defined objects such as tripal cvterms')");
     }
-    tripal_db_set_active($previous_db);  // now use drupal database
   }
 
   // add some variables for all javasript to use for building URLs
   global $base_url;
   $theme_dir = drupal_get_path('theme', 'tripal');
-  $clean_urls  = variable_get('clean_url', 0);
+  $clean_urls = variable_get('clean_url', 0);
   drupal_add_js(
     " var baseurl  = '$base_url';
       var themedir = '$theme_dir';
@@ -234,30 +223,6 @@ function tripal_core_perm() {
   return array();
 }
 
-/**
- * Check whether chado is installed (either in the same or a different database)
- *
- * @return
- *   TRUE/FALSE depending upon whether chado is installed.
- *
- * @ingroup tripal_chado_api
- */
-function tripal_core_is_chado_installed() {
-  global $db_url, $db_type;
-
-  // first check if chado is in the db_url of the
-  // settings.php file
-  if (is_array($db_url)) {
-    if (isset($db_url['chado'])) {
-      return TRUE;
-    }
-  }
-
-  // check to make sure the chado schema exists
-  return tripal_core_chado_schema_exists();
-}
-
-
 /**
  * Implements hook_theme().
  * Registers template files/functions used by this module.

+ 1 - 11
tripal_cv/tripal_cv.install

@@ -15,15 +15,6 @@ function tripal_cv_install() {
   // create the module's data directory
   tripal_create_moddir('tripal_cv');
 
-  // Add the materialized view needed to keep track of the
-  //
-  $previous_db = tripal_db_set_active('chado');
-  if (db_table_exists('cv_root_mview')) {
-    $sql = "DROP TABLE cv_root_mview";
-    db_query($sql);
-  }
-  tripal_db_set_active($previous_db);
-
   // Create the MView
   tripal_add_mview(
     // view name
@@ -156,8 +147,7 @@ function tripal_cv_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    $version = tripal_core_set_chado_version();
-    if ($version == 'not installed') {
+    if (!tripal_core_is_chado_installed()) {
       $requirements ['tripal_cv'] = array(
             'title' => "tripal_cv",
             'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 1 - 2
tripal_db/tripal_db.install

@@ -33,8 +33,7 @@ function tripal_db_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    $version = tripal_core_set_chado_version();
-    if ($version == 'not installed') {
+    if (!tripal_core_is_chado_installed()) {
       $requirements ['tripal_db'] = array(
             'title' => "tripal_db",
             'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 1 - 2
tripal_feature/tripal_feature.install

@@ -183,8 +183,7 @@ function tripal_feature_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    $version = tripal_core_set_chado_version();
-    if ($version == 'not installed') {
+    if (!tripal_core_is_chado_installed()) {
       $requirements ['tripal_feature'] = array(
             'title' => "tripal_feature",
             'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 1 - 2
tripal_featuremap/tripal_featuremap.install

@@ -96,8 +96,7 @@ function tripal_featuremap_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    $version = tripal_core_set_chado_version();
-    if ($version == 'not installed') {
+    if (!tripal_core_is_chado_installed()) {
       $requirements ['tripal_featuremap'] = array(
             'title' => "tripal_featuremap",
             'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 1 - 2
tripal_library/tripal_library.install

@@ -145,8 +145,7 @@ function tripal_library_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    $version = tripal_core_set_chado_version();
-    if ($version == 'not installed') {
+    if (!tripal_core_is_chado_installed()) {
       $requirements ['tripal_library'] = array(
             'title' => "tripal_library",
             'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 1 - 2
tripal_organism/tripal_organism.install

@@ -116,8 +116,7 @@ function tripal_organism_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    $version = tripal_core_set_chado_version();
-    if ($version == 'not installed') {
+    if (!tripal_core_is_chado_installed()) {
       $requirements ['tripal_organism'] = array(
             'title' => "tripal_organism",
             'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 1 - 2
tripal_project/tripal_project.install

@@ -72,8 +72,7 @@ function tripal_project_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    $version = tripal_core_set_chado_version();
-    if ($version == 'not installed') {
+    if (!tripal_core_is_chado_installed()) {
       $requirements ['tripal_project'] = array(
             'title' => "tripal_project",
             'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 1 - 2
tripal_stock/tripal_stock.install

@@ -75,8 +75,7 @@ function tripal_stock_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    $version = tripal_core_set_chado_version();
-    if ($version == 'not installed') {
+    if (!tripal_core_is_chado_installed()) {
       $requirements ['tripal_stock'] = array(
             'title' => "tripal_stock",
             'value' => "ERROR: Chado most be installed before this module can be enabled",