You are here

function poll_install in Drupal 5

Same name and namespace in other branches
  1. 6 modules/poll/poll.install \poll_install()

Implementation of hook_install().

File

modules/poll/poll.install, line 6

Code

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;
  }
}