function tripal_example_add_example_table
2.x tripal_example.install | tripal_example_add_example_table() |
Adds the 'example' custom table to Chado.
1 call to tripal_example_add_example_table()
- tripal_example_add_custom_tables in tripal_example/
tripal_example.install - Add custom tables to Chado that are required by this module
File
- tripal_example/
tripal_example.install, line 288 - Installation of the example module
Code
function tripal_example_add_example_table() {
// EXPLANATION: use the Drupal Schema API to describe the custom table. Then
// add the table using the chado_create_custom_table() function.
$schema = array(
'table' => 'example',
'fields' => array(
'example_id' => array(
'type' => 'serial',
'not null' => true,
),
'uniquename' => array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
),
'type_id' => array(
'type' => 'int',
'not null' => true,
),
'organism_id' => array(
'type' => 'int',
'not null' => true,
),
'description' => array(
'type' => 'text',
),
),
'primary key' => array(
0 => 'example_id',
),
'unique keys' => array(
'example_uq1' => array(
0 => 'uniquename',
1 => 'type_id',
2 => 'organism_id',
),
),
'indexes' => array(
'example_idx1' => array(
0 => 'example_id',
),
'example_idx2' => array(
0 => 'uniquename',
),
),
'foreign keys' => array(
'cvterm' => array(
'table' => 'cvterm',
'columns' => array(
'type_id' => 'cvterm_id',
),
),
'organism' => array(
'table' => 'organism',
'columns' => array(
'organism_id' => 'organism_id',
),
),
),
// EXPLANATION: the 'referring_tables' array is the list of tables that have
// a foreign key relationships with this table. This information is required
// for the Tripal API to be able to expand tables in templates.
'referring_tables' => array(
0 => 'example_relationship',
1 => 'exampleprop',
2 => 'example_dbxref',
),
);
chado_create_custom_table('example', $schema, TRUE);
}