array( 'obo_id' => array( 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE ), 'name' => array( 'type' => 'varchar', 'length' => 255 ), 'path' => array( 'type' => 'varchar', 'length' => 1024 ), ), 'indexes' => array( 'tripal_cv_obo_idx1' => array('obo_id'), ), 'primary key' => array('obo_id'), ); } /** * * Table definition for the tripal_cv_defaults table * @param unknown $schema */ function tripal_chado_tripal_cv_defaults_schema() { return array( 'fields' => array( 'cv_default_id' => array( 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE ), 'table_name' => array( 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, ), 'field_name' => array( 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, ), 'cv_id' => array( 'type' => 'int', 'not null' => TRUE, ) ), 'indexes' => array( 'tripal_cv_defaults_idx1' => array('table_name', 'field_name'), ), 'unique keys' => array( 'tripal_cv_defaults_unq1' => array('table_name', 'field_name', 'cv_id'), ), 'primary key' => array('cv_default_id') ); } /** * Implements hook_schema(). */ function tripal_chado_schema() { // Links TripalEntity entities to the chado record. $schema['chado_entity'] = tripal_chado_chado_entity_schema(); $schema['tripal_mviews'] = tripal_chado_tripal_mviews_schema(); $schema['tripal_custom_tables'] = tripal_chado_tripal_custom_tables_schema(); $schema['tripal_cv_obo'] = tripal_chado_tripal_cv_obo_schema(); $schema['tripal_cv_defaults'] = tripal_chado_tripal_cv_defaults_schema(); $schema['tripal_pub_import'] = tripal_chado_tripal_pub_import_schema(); // if this module is already installed and enabled, then we want to provide // the schemas for all of the custom tables. This will allow Views to // see the schemas. We check if the module is installed because during // installation we don't want to make these custom tables available as we don't // want them created in the Drupal database. The custom tables go in the // Chado database. if (db_table_exists('tripal_custom_tables')) { $sql = 'SELECT * FROM {tripal_custom_tables}'; $results = db_query($sql); foreach ($results as $custom) { $schema[$custom->table_name] = unserialize($custom->schema); } } return $schema; } /** * @section * Schema Definitions. */ /** * Implementation of hook_schema(). * * @ingroup tripal_pub */ function tripal_chado_tripal_pub_import_schema() { return array( 'fields' => array( 'pub_import_id' => array( 'type' => 'serial', 'not null' => TRUE ), 'name' => array( 'type' => 'varchar', 'length' => 255, 'not null' => TRUE ), 'criteria' => array( 'type' => 'text', 'size' => 'normal', 'not null' => TRUE, 'description' => 'Contains a serialized PHP array containing the search criteria' ), 'disabled' => array( 'type' => 'int', 'unsigned' => TRUE, 'not NULL' => TRUE, 'default' => 0 ), 'do_contact' => array( 'type' => 'int', 'unsigned' => TRUE, 'not NULL' => TRUE, 'default' => 0 ), ), 'primary key' => array('pub_import_id'), 'indexes' => array( 'name' => array('name') ), ); } /** * Describes the Tripal Custom Tables (tripal_custom_tables) table * This keeps track of tables created by Tripal and stored in chado that may or may not * also be materialized views. * * @ingroup tripal */ function tripal_chado_tripal_custom_tables_schema() { return array( 'fields' => array( 'table_id' => array( 'type' => 'serial', 'unsigned' => TRUE, 'not NULL' => TRUE ), 'table_name' => array( 'type' => 'varchar', 'length' => 255, 'not NULL' => TRUE ), 'schema' => array( 'type' => 'text', 'not NULL' => TRUE ), 'mview_id' => array( 'type' => 'int', 'not NULL' => FALSE ) ), 'indexes' => array( 'table_id' => array('table_id'), ), 'primary key' => array('table_id'), 'foreign keys' => array( 'tripal_mviews' => array( 'table' => 'tripal_mviews', 'columns' => array( 'mview_id' => 'mview_id' ), ), ), ); } /** * Describes the Tripal Materialized View (tripal_mviews) table * This table keeps track of all materialized views created by Tripal and stored in chado * * @ingroup tripal */ function tripal_chado_tripal_mviews_schema() { return array( 'fields' => array( 'mview_id' => array( 'type' => 'serial', 'unsigned' => TRUE, 'not NULL' => TRUE ), 'name' => array( 'type' => 'varchar', 'length' => 255, 'not NULL' => TRUE ), 'modulename' => array( 'type' => 'varchar', 'length' => 50, 'not NULL' => TRUE, 'description' => 'The module name that provides the callback for this job' ), 'mv_table' => array( 'type' => 'varchar', 'length' => 128, 'not NULL' => FALSE ), 'mv_specs' => array( 'type' => 'text', 'size' => 'normal', 'not NULL' => FALSE ), 'mv_schema' => array( 'type' => 'text', 'size' => 'normal', 'not NULL' => FALSE ), 'indexed' => array( 'type' => 'text', 'size' => 'normal', 'not NULL' => FALSE ), 'query' => array( 'type' => 'text', 'size' => 'normal', 'not NULL' => TRUE ), 'special_index' => array( 'type' => 'text', 'size' => 'normal', 'not NULL' => FALSE ), 'last_update' => array( 'type' => 'int', 'not NULL' => FALSE, 'description' => 'UNIX integer time' ), 'status' => array( 'type' => 'text', 'size' => 'normal', 'not NULL' => FALSE ), 'comment' => array( 'type' => 'text', 'size' => 'normal', 'not NULL' => FALSE ), ), 'indexes' => array( 'mview_id' => array('mview_id') ), 'unique keys' => array( 'mv_table' => array('mv_table'), 'mv_name' => array('name'), ), 'primary key' => array('mview_id'), ); } /** * Links Biological Data Entities to the chado "base" table the data is stored in. * This is where we would specify that a particular gene maps to the record in the * chado.feature table with a feature_id=2432; */ function tripal_chado_chado_entity_schema() { $schema = array( 'description' => 'The linker table that associates an enitity from the public.tripal_entity table with a "base" record in Chado', 'fields' => array( 'chado_entity_id' => array( 'description' => 'The primary identifier for this table.', 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, ), 'entity_id' => array( 'description' => 'The unique entity id.', 'type' => 'int', 'not null' => TRUE, ), 'record_id' => array( 'description' => 'The unique numerical identifier for the record that this entity is associated with (e.g. feature_id, stock_id, library_id, etc.).', 'type' => 'int', 'not null' => TRUE, ), 'data_table' => array( 'description' => 'Indicates the table in Chado that this term services (e.g. feature, stock, library, etc.)', 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '', ), 'type_table' => array( 'description' => 'Sometimes the record in the data table doesn’t have a field that specifies the record type. For example, an analysis type is stored in the analysisprop table. If the data_table does have a type field then this value will be the same as the data_table.', 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '', ), 'field' => array( 'description' => 'The name of the field in the typetable that contains the cvterm record.', 'type' => 'varchar', 'length' => 128, 'not null' => FALSE, 'default' => '' ), ), 'indexes' => array( 'record_id' => array('record_id'), 'entity_id' => array('entity_id'), 'data_table' => array('data_table'), ), 'unique keys' => array( 'record' => array('data_table', 'record_id'), 'entity_id' => array('entity_id'), ), 'primary key' => array('chado_entity_id'), ); return $schema; }