Newer
Older
Dries Buytaert
committed
<?php
/**
* @file
Angie Byron
committed
* Install, update and uninstall functions for the poll module.
Dries Buytaert
committed
/**
Dries Buytaert
committed
* Implements hook_schema().
Dries Buytaert
committed
*/
function poll_schema() {
$schema['poll'] = array(
Dries Buytaert
committed
'description' => 'Stores poll-specific information for poll nodes.',
Dries Buytaert
committed
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
Dries Buytaert
committed
'description' => "The poll's {node}.nid.",
'runtime' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
Dries Buytaert
committed
'description' => 'The number of seconds past {node}.created during which the poll is open.',
),
'active' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
Dries Buytaert
committed
'description' => 'Boolean indicating whether or not the poll is open.',
Dries Buytaert
committed
'primary key' => array('nid'),
'foreign keys' => array(
Dries Buytaert
committed
'poll_node' => array(
'table' => 'node',
'columns' => array('nid' => 'nid'),
),
Dries Buytaert
committed
$schema['poll_choice'] = array(
Dries Buytaert
committed
'description' => 'Stores information about all choices for all {poll}s.',
Dries Buytaert
committed
'fields' => array(
'chid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
Dries Buytaert
committed
'description' => 'Unique identifier for a poll choice.',
),
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
Dries Buytaert
committed
'description' => 'The {node}.nid this choice belongs to.',
),
'chtext' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
Dries Buytaert
committed
'description' => 'The text for this choice.',
Dries Buytaert
committed
'translatable' => TRUE,
'chvotes' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
Dries Buytaert
committed
'description' => 'The total number of votes this choice has received by all users.',
Dries Buytaert
committed
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
Dries Buytaert
committed
'description' => 'The sort order of this choice among all choices for the same node.',
'indexes' => array(
'nid' => array('nid'),
),
Dries Buytaert
committed
'primary key' => array('chid'),
'foreign keys' => array(
Dries Buytaert
committed
'choice_node' => array(
'table' => 'node',
'columns' => array('nid' => 'nid'),
),
$schema['poll_vote'] = array(
Angie Byron
committed
'description' => 'Stores per-{users} votes for each {poll}.',
Dries Buytaert
committed
'fields' => array(
Dries Buytaert
committed
'chid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
Angie Byron
committed
'description' => "The {users}'s vote for this poll.",
Dries Buytaert
committed
),
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
Dries Buytaert
committed
'description' => 'The {poll} node this vote is for.',
),
'uid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
Angie Byron
committed
'description' => 'The {users}.uid this vote is from unless the voter was anonymous.',
'hostname' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
Dries Buytaert
committed
'description' => 'The IP address this vote is from unless the voter was logged in.',
'timestamp' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The timestamp of the vote creation.',
),
Dries Buytaert
committed
'primary key' => array('nid', 'uid', 'hostname'),
'foreign keys' => array(
Dries Buytaert
committed
'poll_node' => array(
'table' => 'node',
'columns' => array('nid' => 'nid'),
),
'voter' => array(
'table' => 'users',
'columns' => array('uid' => 'uid'),
),
Dries Buytaert
committed
'indexes' => array(
Dries Buytaert
committed
'chid' => array('chid'),
Dries Buytaert
committed
'hostname' => array('hostname'),
'uid' => array('uid'),
),
);
Dries Buytaert
committed
return $schema;
}