annotate modules/poll/poll.install @ 19:3edae6ecd6c6 6.9

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