You are here

poll.install in Drupal 5

Same filename and directory in other branches
  1. 6 modules/poll/poll.install
  2. 7 modules/poll/poll.install

File

modules/poll/poll.install
View source
<?php

/**
 * Implementation of hook_install().
 */
function poll_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {poll} (\n        nid int unsigned NOT NULL default '0',\n        runtime int NOT NULL default '0',\n        active int unsigned NOT NULL default '0',\n        PRIMARY KEY (nid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {poll_votes} (\n        nid int unsigned NOT NULL,\n        uid int unsigned NOT NULL default 0,\n        chorder int NOT NULL default -1,\n        hostname varchar(128) NOT NULL default '',\n        INDEX (nid),\n        INDEX (uid),\n        INDEX (hostname)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {poll_choices} (\n        chid int unsigned NOT NULL auto_increment,\n        nid int unsigned NOT NULL default '0',\n        chtext varchar(128) NOT NULL default '',\n        chvotes int NOT NULL default '0',\n        chorder int NOT NULL default '0',\n        PRIMARY KEY (chid),\n        KEY nid (nid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {poll} (\n        nid int_unsigned NOT NULL default '0',\n        runtime int NOT NULL default '0',\n        active int_unsigned NOT NULL default '0',\n        PRIMARY KEY (nid)\n      )");
      db_query("CREATE TABLE {poll_votes} (\n        nid int_unsigned NOT NULL,\n        uid int_unsigned NOT NULL default 0,\n        chorder int NOT NULL default -1,\n        hostname varchar(128) NOT NULL default ''\n      )");
      db_query("CREATE INDEX {poll_votes}_nid_idx ON {poll_votes} (nid)");
      db_query("CREATE INDEX {poll_votes}_uid_idx ON {poll_votes} (uid)");
      db_query("CREATE INDEX {poll_votes}_hostname_idx ON {poll_votes} (hostname)");
      db_query("CREATE TABLE {poll_choices} (\n        chid serial CHECK (chid >= 0),\n        nid int_unsigned NOT NULL default '0',\n        chtext varchar(128) NOT NULL default '',\n        chvotes int NOT NULL default '0',\n        chorder int NOT NULL default '0',\n        PRIMARY KEY (chid)\n      )");
      db_query("CREATE INDEX {poll_choices}_nid_idx ON {poll_choices} (nid)");
      break;
  }
}

/**
 * Implementation of hook_uninstall().
 */
function poll_uninstall() {
  db_query('DROP TABLE {poll}');
  db_query('DROP TABLE {poll_votes}');
  db_query('DROP TABLE {poll_choices}');
}

Functions

Namesort descending Description
poll_install Implementation of hook_install().
poll_uninstall Implementation of hook_uninstall().