You are here

function votingapi_install in Voting API 5

Same name and namespace in other branches
  1. 6.2 votingapi.install \votingapi_install()
  2. 6 votingapi.install \votingapi_install()

File

./votingapi.install, line 4

Code

function votingapi_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {votingapi_vote} (\n          vote_id int(10) unsigned NOT NULL,\n          content_type varchar(20) default NULL,\n          content_id int(10) unsigned default NULL,\n          value float(10) default NULL,\n          value_type varchar(20) NOT NULL,\n          tag varchar(128) default 'vote',\n          uid int(10) unsigned default '0',\n          timestamp int(11) default NULL,\n          hostname varchar(128) default '0',\n          PRIMARY KEY (vote_id),\n          INDEX content (content_type, content_id)\n        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      db_query("CREATE TABLE {votingapi_cache} (\n          vote_cache_id int(10) unsigned NOT NULL,\n          content_type varchar(20) default NULL,\n          content_id int(10) unsigned default NULL,\n          value float(10) default NULL,\n          value_type varchar(20) NOT NULL,\n          tag varchar(128) default 'vote',\n          function varchar(128) default 'count',\n          timestamp int(11) default NULL,\n          PRIMARY KEY (vote_cache_id),\n          INDEX content (content_type, content_id)\n        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {votingapi_vote} (\n          vote_id int4 NOT NULL,\n          content_type varchar(20) default NULL,\n          content_id int4 default NULL,\n          value float(10) default NULL,\n          value_type varchar(20) NOT NULL,\n          tag varchar(128) default 'vote',\n          uid int4 default '0',\n          timestamp int4 default NULL,\n          hostname varchar(128) default '0',\n          PRIMARY KEY (vote_id));");
      db_query("CREATE SEQUENCE {votingapi_vote}_seq;");
      db_query("CREATE INDEX {votingapi_vote}_content_type_id_idx\n          ON {votingapi_vote} (content_type, content_id);");
      db_query("CREATE TABLE {votingapi_cache} (\n          vote_cache_id int4 NOT NULL,\n          content_type varchar(20) default NULL,\n          content_id int4 default NULL,\n          value float(10) default NULL,\n          value_type varchar(20) NOT NULL,\n          tag varchar(128) default 'vote',\n          function varchar(128) default 'count',\n          timestamp int4 default NULL,\n          PRIMARY KEY (vote_cache_id));");
      db_query("CREATE SEQUENCE {votingapi_cache}_seq;");
      db_query("CREATE INDEX {votingapi_cache}_content_type_id_idx\n          ON {votingapi_cache} (content_type, content_id);");
      break;
  }
}