poll.install

  1. 7.x drupal-7.x/modules/poll/poll.install
  2. 6.x drupal-6.x/modules/poll/poll.install

File

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