function crm_core_contact_schema in CRM Core 7
Implements hook_schema().
File
- modules/
crm_core_contact/ crm_core_contact.install, line 73 - Install, update and uninstall functions for the CRM Core Contact module.
Code
function crm_core_contact_schema() {
$schema['crm_core_contact'] = array(
'description' => 'Stores contact data.',
'fields' => array(
'contact_id' => array(
'description' => 'The primary identifer for a contact.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'vid' => array(
'description' => 'The current {crm_core_contact_revision}.vid of this contact.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'type' => array(
'description' => 'The {crm_core_contact_type}.type of contact.',
'type' => 'varchar',
'length' => 40,
'not null' => TRUE,
'default' => '',
),
'created' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Timestamp for when contact was created.',
),
'changed' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Timestamp for when contact was last changed',
),
'uid' => array(
'description' => 'The {users}.uid that owns this contact; initially, this is the user that created it.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'name' => array(
'description' => 'Plain text contact name used in DB queries. Updated on contact update.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
),
'indexes' => array(
'created' => array(
'created',
),
'changed' => array(
'changed',
),
'contact_name' => array(
'name',
),
),
'foreign keys' => array(
'contact_revision' => array(
'table' => 'crm_core_contact_revision',
'columns' => array(
'vid' => 'vid',
),
),
),
'primary key' => array(
'contact_id',
),
);
$schema['crm_core_contact_revision'] = array(
'description' => 'Saves information about each saved revision of a {crm_core_contact}',
'fields' => array(
'vid' => array(
'description' => 'The primary identifier of this {crm_core_contact_revision}.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'contact_id' => array(
'description' => 'The {crm_core_contact}.contact_id for this revision.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'log' => array(
'description' => 'The log entry explaining the changes in this version.',
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
),
'created' => array(
'description' => 'The unix timestamp for when this revision was created.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'changed' => array(
'description' => 'The unix timestamp for when this revision was last changed.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'uid' => array(
'description' => 'The {users}.uid that created this version.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'foreign keys' => array(
'versioned_contact' => array(
'table' => 'crm_core_contact',
'columns' => array(
'contact_id' => 'contact_id',
),
),
'version_creator' => array(
'table' => 'user',
'columns' => array(
'uid' => 'uid',
),
),
),
'primary key' => array(
'vid',
),
);
$schema['crm_core_contact_type'] = array(
'description' => 'Stores information about all defined contact types.',
'fields' => array(
'id' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique contact type ID.',
),
'type' => array(
'description' => 'The machine-readable name of this type.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'name' => array(
'description' => 'The human-readable name of this type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'translatable' => TRUE,
),
'description' => array(
'description' => 'A brief description of this type.',
'type' => 'text',
'not null' => TRUE,
'size' => 'medium',
'translatable' => TRUE,
),
'custom' => array(
'description' => 'A boolean indicating whether this type is defined by a module (FALSE) or by a user via Add content type (TRUE).',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
),
'disabled' => array(
'description' => 'A boolean indicating whether this type is disabled or not, disabled contact type contacts will not show up in the list of contacts',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
),
'locked' => array(
'description' => 'A boolean indicating whether this type is locked or not, locked contact type cannot be edited or disabled/deleted',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
),
'primary_fields' => array(
'description' => 'Serialized array of key-value pairs, where key is the primary field type and value is real field name used for this type.',
'type' => 'blob',
'serialize' => TRUE,
),
) + entity_exportable_schema_fields(),
'primary key' => array(
'id',
),
'unique keys' => array(
'type' => array(
'type',
),
),
);
if (module_exists('uuid')) {
$field = uuid_schema_field_definition();
$schema['crm_core_contact']['fields']['uuid'] = $field;
$schema['crm_core_contact']['indexes']['uuid'] = array(
'uuid',
);
$schema['crm_core_contact_revision']['fields']['vuuid'] = $field;
$schema['crm_core_contact_revision']['indexes']['vuuid'] = array(
'vuuid',
);
}
return $schema;
}