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
|
<?php
// $Id$
/**
* 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(
'fields' => array(
'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
'runtime' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
'active' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
),
'primary key' => array('nid'),
);
$schema['poll_choices'] = array(
'fields' => array(
'chid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
'chtext' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
'chvotes' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
'chorder' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)
),
'indexes' => array('nid' => array('nid')),
'primary key' => array('chid'),
);
$schema['poll_votes'] = array(
'fields' => array(
'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
'chorder' => array('type' => 'int', 'not null' => TRUE, 'default' => -1),
'hostname' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '')
),
'indexes' => array(
'hostname' => array('hostname'),
'nid' => array('nid'),
'uid' => array('uid')
),
);
return $schema;
}
|