function tripal_core_reset_chado_schema

2.x tripal_core.chado_install.inc tripal_core_reset_chado_schema()
1.x chado_install.inc tripal_core_reset_chado_schema()

Reset the Chado Schema This drops the current chado and chado-related schema and re-creates it

Related topics

1 call to tripal_core_reset_chado_schema()
tripal_core_install_chado in tripal_core/includes/chado_install.inc
Install Chado Schema

File

tripal_core/includes/chado_install.inc, line 171
Functions to install chado schema through Drupal

Code

function tripal_core_reset_chado_schema() {
  global $active_db;

  // drop current chado and chado-related schema
  if (tripal_core_schema_exists('chado')) {
    print "Dropping existing 'chado' schema\n";
    db_query("drop schema chado cascade");
  }
  if (tripal_core_schema_exists('genetic_code')) {
    print "Dropping existing 'genetic_code' schema\n";
    db_query("drop schema genetic_code cascade");
  }
  if (tripal_core_schema_exists('so')) {
    print "Dropping existing 'so' schema\n";
    db_query("drop schema so cascade");
  }
  if (tripal_core_schema_exists('frange')) {
    print "Dropping existing 'frange' schema\n";
    db_query("drop schema frange cascade");
  }

  // create the new chado schema
  print "Creating 'chado' schema\n";
  db_query("create schema chado");
  if (tripal_core_schema_exists('chado')) {
    // before creating the plpgsql language let's check to make sure
    // it doesn't already exists
    $sql = "SELECT COUNT(*) FROM pg_language WHERE lanname = 'plpgsql'";
    $count = db_fetch_object(db_query($sql));
    if (!$count or $count->count == 0) {
      db_query("create language plpgsql");
    }
    return TRUE;
  }

  return FALSE;
}