You are here

function og_menu_install in Organic Groups Menu (OG Menu) 5

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

File

./og_menu.install, line 4

Code

function og_menu_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':

      // the {tablename} syntax is so multisite installs can add a
      // prefix to the table name as set in the settings.php file
      db_query("CREATE TABLE {og_menu} (\n          mid int unsigned NOT NULL default '0',\n          gid int unsigned NOT NULL default '0',\n          is_primary tinyint unsigned NOT NULL default '0',\n          parent_mid int unsigned NOT NULL default '0',\n          weight int NOT NULL default '0',\n          PRIMARY KEY  (mid)\n        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {og_menu} (\n          mid integer NOT NULL default '0' CHECK (mid >= 0),\n          gid  integer NOT NULL default '0' CHECK (gid >= 0),\n          is_primary integer NOT NULL default '0' CHECK (is_primary >= 0),\n          parent_mid integer NOT NULL default '0' CHECK (parent_mid >= 0),\n          weight integer NOT NULL default '0',\n          PRIMARY KEY  (mid)\n        )");

      // Pgsql requires keys and indexes to be defined separately.
      // It's important to name the index as {tablename}_fieldname_idx
      // (the trailing _idx!) so update scripts can be written easily
      db_query("CREATE INDEX {og_menu}_mid_idx\n                ON {og_menu} (mid)");
      break;
  }
}