function pollim_schema in Poll Improved 7
Implements hook_schema().
File
- ./
pollim.install, line 13 - Sets up the base table for our entity and a table to store information about the entity types.
Code
function pollim_schema() {
$schema = array();
$schema['pollim'] = array(
'description' => 'The base table for pollim entities.',
'fields' => array(
'pollim_id' => array(
'description' => 'Primary Key: Identifier for a pollim.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'type' => array(
'description' => 'The {pollim_type}.type of this pollim.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'language' => array(
'description' => 'The language of the pollim.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'name' => array(
'description' => 'The name of the pollim - a human-readable identifier.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'created' => array(
'description' => 'The Unix timestamp when the pollim was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'changed' => array(
'description' => 'The Unix timestamp when the pollim was most recently saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'data' => array(
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
'description' => 'A serialized array of additional data.',
),
),
'primary key' => array(
'pollim_id',
),
'indexes' => array(
'type_index' => array(
'type',
),
),
);
$schema['pollim_type'] = array(
'description' => 'Stores information about defined pollim types.',
'fields' => array(
'id' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique pollim type identifier.',
),
'type' => array(
'description' => 'The machine-readable name of this pollim type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'label' => array(
'description' => 'The human-readable name of this pollim 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 pollim type in relation to others.',
),
'data' => array(
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
'description' => 'A serialized array of additional data related to this pollim type.',
),
) + entity_exportable_schema_fields(),
'primary key' => array(
'id',
),
'unique keys' => array(
'type' => array(
'type',
),
),
);
$schema['pollim_vote'] = array(
'description' => 'The base table for pollim votes.',
'fields' => array(
'vote_id' => array(
'description' => 'Primary Key: Identifier for a vote.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'timestamp' => array(
'description' => 'The Unix timestamp when the vote was saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'pollim_id' => array(
'description' => 'Reference to the Pollim entity.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'hostname' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
),
'data' => array(
'type' => 'varchar',
'not null' => FALSE,
'length' => 255,
'default' => '',
),
),
'primary key' => array(
'vote_id',
),
'indexes' => array(
'type_index' => array(
'pollim_id',
),
),
);
return $schema;
}