1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
<?php
/**
* Implementation of hook_install().
*/
function poll_install() {
// Create tables.
drupal_install_schema('poll');
}
/**
* Implementation of hook_uninstall().
*/
function poll_uninstall() {
// Remove tables.
drupal_uninstall_schema('poll');
}
/**
* Implementation of hook_schema().
*/
function poll_schema() {
$schema['poll'] = array(
'description' => 'Stores poll-specific information for poll nodes.',
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => "The poll's {node}.nid."
),
'runtime' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'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,
'description' => 'Boolean indicating whether or not the poll is open.',
),
),
'primary key' => array('nid'),
);
$schema['poll_choices'] = array(
'description' => 'Stores information about all choices for all {poll}s.',
'fields' => array(
'chid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Unique identifier for a poll choice.',
),
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The {node}.nid this choice belongs to.',
),
'chtext' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'The text for this choice.',
),
'chvotes' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The total number of votes this choice has received by all users.',
),
'chorder' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The sort order of this choice among all choices for the same node.',
)
),
'indexes' => array(
'nid' => array('nid')
),
'primary key' => array('chid'),
);
$schema['poll_votes'] = array(
'description' => 'Stores per-{users} votes for each {poll}.',
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'The {poll} node 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.',
),
'chorder' => array(
'type' => 'int',
'not null' => TRUE,
'default' => -1,
'description' => "The {users}'s vote for this poll.",
),
'hostname' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'The IP address this vote is from unless the voter was logged in.',
),
),
'primary key' => array('nid', 'uid', 'hostname'),
'indexes' => array(
'hostname' => array('hostname'),
'uid' => array('uid'),
),
);
return $schema;
}
|