function redhen_org_schema in RedHen CRM 7
Implements hook_schema().
File
- modules/
redhen_org/ redhen_org.install, line 11 - Schema and installation hooks for redhen_org module.
Code
function redhen_org_schema() {
$schema['redhen_org'] = array(
'description' => 'The base table for redhen_org module.',
'fields' => array(
'org_id' => array(
'description' => 'The primary identifier for a redhen_org.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'revision_id' => array(
'description' => 'The current {redhen_org_revision}.revision_id version identifier.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'type' => array(
'description' => 'The {redhen_org_type}.type of this redhen_org.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'label' => array(
'description' => 'The label of this redhen_org, always treated as non-markup plain text.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'author_uid' => array(
'description' => 'The uid of the user who created this redhen_org.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'primary_contact_id' => array(
'description' => 'The redhen_contact.contact_id of the primary contact.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'redhen_state' => array(
'description' => 'The redhen_state of this redhen_org.',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
),
'created' => array(
'description' => 'The Unix timestamp when the redhen_org was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'updated' => array(
'description' => 'The Unix timestamp when the redhen_org was most recently saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'indexes' => array(
'redhen_org_updated' => array(
'updated',
),
'redhen_org_created' => array(
'created',
),
'redhen_org_type' => array(
array(
'type',
4,
),
),
'redhen_org_redhen_state' => array(
'redhen_state',
),
'redhen_org_revision' => array(
'revision_id',
),
'redhen_org_author' => array(
'author_uid',
),
'redhen_org_primary_contact_id' => array(
'primary_contact_id',
),
'redhen_org_label' => array(
'label',
),
),
'foreign keys' => array(
'redhen_org_revision' => array(
'table' => 'redhen_org_revision',
'columns' => array(
'revision_id' => 'revision_id',
),
),
'redhen_org_author' => array(
'table' => 'users',
'columns' => array(
'author_uid' => 'uid',
),
),
'redhen_org_type' => array(
'table' => 'redhen_org_type',
'columns' => array(
'type' => 'name',
),
),
'redhen_org_primary_contact_id' => array(
'table' => 'redhen_contact',
'columns' => array(
'primary_contact_id' => 'contact_id',
),
),
),
'primary key' => array(
'org_id',
),
);
// Revisions table.
$schema['redhen_org_revision'] = array(
'description' => 'The revision table for redhen_org module.',
'fields' => array(
'org_id' => array(
'description' => 'The primary identifier for a redhen_org.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'revision_id' => array(
'description' => 'The version identifier of this revision.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'label' => array(
'description' => 'The label of this redhen_org, always treated as non-markup plain text.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'author_uid' => array(
'description' => 'The uid of the user who created this redhen_org.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'primary_contact_id' => array(
'description' => 'The redhen_contact.contact_id of the primary contact.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'redhen_state' => array(
'description' => 'The redhen_state of this redhen_org.',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
),
'log' => array(
'description' => 'The log entry explaining the changes in this version.',
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
),
'updated' => array(
'description' => 'The Unix timestamp when the redhen_org was most recently saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'indexes' => array(
'redhen_org_updated_revision' => array(
'updated',
),
'redhen_org_redhen_state_revision' => array(
'redhen_state',
),
'revision_redhen_org' => array(
'org_id',
),
'redhen_org_revision_author' => array(
'author_uid',
),
'redhen_org_revision_primary_contact_id' => array(
'primary_contact_id',
),
'redhen_org_revision_label' => array(
'label',
),
),
'foreign keys' => array(
'revision_redhen_org' => array(
'table' => 'redhen_org',
'columns' => array(
'org_id' => 'org_id',
),
),
'redhen_org_revision_author' => array(
'table' => 'users',
'columns' => array(
'author_uid' => 'uid',
),
),
'redhen_org_revision_primary_contact_id' => array(
'table' => 'redhen_contact',
'columns' => array(
'primary_contact_id' => 'contact_id',
),
),
),
'primary key' => array(
'revision_id',
),
);
$schema['redhen_org_type'] = array(
'description' => 'Stores information about all defined org types.',
'fields' => array(
'org_type_id' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique org type ID.',
),
'name' => array(
'description' => 'The machine-readable name of this org type.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'label' => array(
'description' => 'The human-readable name of this org type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'The weight of this org type in relation to others.',
),
'locked' => array(
'description' => 'A boolean indicating whether the administrator may delete this type.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
),
'data' => array(
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
'description' => 'A serialized array of additional data related to this org type.',
'merge' => TRUE,
),
'status' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0x1,
'size' => 'tiny',
'description' => 'The exportable status of the entity.',
),
'module' => array(
'description' => 'The name of the providing module if the entity has been defined in code.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
),
'primary key' => array(
'org_type_id',
),
'unique keys' => array(
'name' => array(
'name',
),
),
);
return $schema;
}