You are here

modr8.install in modr8 5

Same filename and directory in other branches
  1. 6 modr8.install
  2. 7 modr8.install

File

modr8.install
View source
<?php

/**
 * Implementation of hook_install().
 */
function modr8_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {modr8_log} (\n        modid int NOT NULL auto_increment,\n        nid int unsigned NOT NULL default '0',\n        uid int NOT NULL default '0',\n        author_uid int NOT NULL default '0',\n        action varchar(16) NOT NULL default '',\n        title varchar(128) NOT NULL default '',\n        message longtext NOT NULL,\n        teaser longtext NOT NULL,\n        timestamp int NOT NULL default '0',\n        PRIMARY KEY (modid),\n        KEY nid_time (nid, modid),\n        KEY action (action)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {modr8_log} (\n        modid serial,\n        nid int_unsigned NOT NULL default '0',\n        uid int NOT NULL default '0',\n        author_uid int NOT NULL default '0',\n        action varchar(16) NOT NULL default '',\n        title varchar(128) NOT NULL default '',\n        message text NOT NULL,\n        teaser text NOT NULL,\n        timestamp int NOT NULL default '0',\n        PRIMARY KEY (modid)\n      )");
      db_query("CREATE INDEX {modr8_log}_nid_time ON {modr8_log} (nid, modid)");
      db_query("CREATE INDEX {modr8_log}_act_idx ON {modr8_log} (action)");
      break;
  }
}

/**
 * Implementation of hook_uninstall().
 */
function modr8_uninstall() {
  db_query('DROP TABLE {modr8_log}');
}

/**
 * Update table definitions.
 */
function modr8_update_1000() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("CREATE TABLE {modr8_log} (\n        modid int NOT NULL auto_increment,\n        nid int unsigned NOT NULL default '0',\n        uid int NOT NULL default '0',\n        author_uid int NOT NULL default '0',\n        action varchar(16) NOT NULL default '',\n        title varchar(128) NOT NULL default '',\n        message longtext NOT NULL,\n        teaser longtext NOT NULL,\n        timestamp int NOT NULL default '0',\n        PRIMARY KEY (modid),\n        KEY nid_time (nid, modid),\n        KEY action (action)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      break;
    case 'pgsql':
      $ret[] = update_sql("CREATE TABLE {modr8_log} (\n        modid serial,\n        nid int_unsigned NOT NULL default '0',\n        uid int NOT NULL default '0',\n        author_uid int NOT NULL default '0',\n        action varchar(16) NOT NULL default '',\n        title varchar(128) NOT NULL default '',\n        message text NOT NULL,\n        teaser text NOT NULL,\n        timestamp int NOT NULL default '0',\n        PRIMARY KEY (modid)\n      )");
      $ret[] = update_sql("CREATE INDEX {modr8_log}_nid_time ON {modr8_log} (nid, modid)");
      $ret[] = update_sql("CREATE INDEX {modr8_log}_act_idx ON {modr8_log} (action)");
      break;
  }
  return $ret;
}

Functions

Namesort descending Description
modr8_install Implementation of hook_install().
modr8_uninstall Implementation of hook_uninstall().
modr8_update_1000 Update table definitions.