Browse Source

Fixed the chado instal script. The db_query() calls had been replaced with chado_query() calls which broke the installer

spficklin 12 years ago
parent
commit
995c9f3198

+ 6 - 4
tripal_analysis/tripal_analysis.install

@@ -21,10 +21,12 @@ function tripal_analysis_install() {
   if (!db_table_exists('analysisfeatureprop')) {
     $sql = "CREATE TABLE analysisfeatureprop (".
             "  analysisfeatureprop_id SERIAL PRIMARY KEY, ".
-            "  analysisfeature_id INTEGER NOT NULL REFERENCES analysisfeature(analysisfeature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, ".
-            "  type_id INTEGER NOT NULL REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, ".
-            "  value TEXT, ".
-            "  rank INTEGER NOT NULL, ".
+            "  analysisfeature_id     INTEGER NOT NULL REFERENCES analysisfeature(analysisfeature_id) " .
+            "    ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, ".
+            "  type_id                INTEGER NOT NULL REFERENCES cvterm(cvterm_id) ".
+            "    ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, ".
+            "  value                  TEXT, ".
+            "  rank                   INTEGER NOT NULL, ".
             "  CONSTRAINT analysisfeature_id_type_id_rank UNIQUE(analysisfeature_id, type_id, rank)".
             ")";
     chado_query($sql);

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

@@ -2882,6 +2882,31 @@ function tripal_core_chado_schema_exists() {
   }
   return TRUE;
 }
+/**
+ * Check that any given schema exists
+ *
+ * @param $schema
+ *   The name of the schema to check the existence of
+ *
+ * @return
+ *   TRUE/FALSE depending upon whether or not the schema exists
+ *
+ * @ingroup tripal_chado_api
+ */
+function tripal_core_schema_exists($schema) {
+
+  // check that the chado schema now exists
+  $sql = "SELECT nspname
+         FROM pg_namespace
+         WHERE has_schema_privilege(nspname, 'USAGE') and nspname = '%s'
+         ORDER BY nspname";
+  $name = db_fetch_object(db_query($sql, $schema));
+  if (strcmp($name->nspname, $schema) != 0) {
+    return FALSE;
+  }
+
+  return TRUE;
+}
 
 /**
  * Retrieves the list tables in the Chado schema.  By default it only retursn
@@ -3193,3 +3218,4 @@ function tripal_core_is_chado_installed() {
   // check to make sure the chado schema exists
   return tripal_core_chado_schema_exists();
 }
+

+ 10 - 36
tripal_core/includes/chado_install.php

@@ -168,58 +168,32 @@ function tripal_core_reset_chado_schema() {
   // drop current chado and chado-related schema
   if (tripal_core_schema_exists('chado')) {
     print "Dropping existing 'chado' schema\n";
-    chado_query("drop schema chado cascade");
+    db_query("drop schema chado cascade");
   }
   if (tripal_core_schema_exists('genetic_code')) {
     print "Dropping existing 'genetic_code' schema\n";
-    chado_query("drop schema genetic_code cascade");
+    db_query("drop schema genetic_code cascade");
   }
   if (tripal_core_schema_exists('so')) {
     print "Dropping existing 'so' schema\n";
-    chado_query("drop schema so cascade");
+    db_query("drop schema so cascade");
   }
   if (tripal_core_schema_exists('frange')) {
     print "Dropping existing 'frange' schema\n";
-    chado_query("drop schema frange cascade");
+    db_query("drop schema frange cascade");
   }
 
   // create the new chado schema
   print "Creating 'chado' schema\n";
-  chado_query("create schema chado");
+  db_query("create schema chado");
   if (tripal_core_schema_exists('chado')) {
-    chado_query("create language plpgsql");
+    db_query("create language plpgsql");
     return TRUE;
   }
 
   return FALSE;
 }
 
-/**
- * Check that a given schema exists
- *
- * @param $schema
- *   The name of the schema to check the existence of
- *
- * @return
- *   TRUE/FALSE depending upon whether or not the schema exists
- *
- * @ingroup tripal_core
- */
-function tripal_core_schema_exists($schema) {
-
-  // check that the chado schema now exists
-  $sql = "SELECT nspname
-         FROM pg_namespace
-         WHERE has_schema_privilege(nspname, 'USAGE') and nspname = '%s'
-         ORDER BY nspname";
-  $name = db_fetch_object(db_query($sql, $schema));
-  if (strcmp($name->nspname, $schema) != 0) {
-    return FALSE;
-  }
-
-  return TRUE;
-}
-
 /**
  * Execute the provided SQL
  *
@@ -230,7 +204,7 @@ function tripal_core_schema_exists($schema) {
  */
 function tripal_core_install_sql($sql_file) {
 
-  chado_query("set search_path to chado,public");
+  db_query("set search_path to chado,public");
   print "Loading $sql_file...\n";
   $lines = file($sql_file, FILE_SKIP_EMPTY_LINES);
 
@@ -370,11 +344,11 @@ function tripal_core_install_sql($sql_file) {
       if (strcmp($type, 'set')==0) {
         $query = preg_replace("/public/m", "chado", $query);
       }
-      $result = chado_query($query);
+      $result = db_query($query);
       if (!$result) {
         $error  = pg_last_error();
         print "FAILED!!\nError Message:\nSQL $i, $in_string: $query\n$error\n";
-        chado_query("set search_path to public,chado");
+        db_query("set search_path to public,chado");
         $success = 0;
       }
       $query = '';
@@ -392,6 +366,6 @@ function tripal_core_install_sql($sql_file) {
 function tripal_core_chado_install_done() {
 
   // return the search path to normal
-  chado_query("set search_path to public,chado");
+  db_query("set search_path to public,chado");
 
 }