comparison modules/poll/poll.install @ 1:c1f4ac30525a 6.0

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