You are here

function poll_schema in Poll 8

Implements hook_schema().

File

./poll.install, line 13
Install, update, and uninstall functions for the Poll module.

Code

function poll_schema() {
  $schema['poll_vote'] = array(
    'description' => 'Stores per-{users} votes for each {poll}.',
    'fields' => array(
      'chid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => "The {users}'s vote for this poll.",
      ),
      'pid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The {poll} entity this vote is for.',
      ),
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The {users}.uid this vote is from unless the voter was anonymous.',
      ),
      'hostname' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        '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.',
      ),
    ),
    'primary key' => array(
      'pid',
      'uid',
      'hostname',
    ),
    'foreign keys' => array(
      'poll_entity' => array(
        'table' => 'poll',
        'columns' => array(
          'pid' => 'pid',
        ),
      ),
      'voter' => array(
        'table' => 'users',
        'columns' => array(
          'uid' => 'uid',
        ),
      ),
    ),
    'indexes' => array(
      'chid' => array(
        'chid',
      ),
      'hostname' => array(
        'hostname',
      ),
      'uid' => array(
        'uid',
      ),
    ),
  );
  return $schema;
}