You are here

function system_install in Drupal 5

Same name and namespace in other branches
  1. 8 core/modules/system/system.install \system_install()
  2. 6 modules/system/system.install \system_install()
  3. 7 modules/system/system.install \system_install()
  4. 9 core/modules/system/system.install \system_install()
  5. 10 core/modules/system/system.install \system_install()

Implementation of hook_install().

File

modules/system/system.install, line 171

Code

function system_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {access} (\n        aid int NOT NULL auto_increment,\n        mask varchar(255) NOT NULL default '',\n        type varchar(255) NOT NULL default '',\n        status tinyint NOT NULL default '0',\n        PRIMARY KEY (aid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {authmap} (\n        aid int unsigned NOT NULL auto_increment,\n        uid int NOT NULL default '0',\n        authname varchar(128) NOT NULL default '',\n        module varchar(128) NOT NULL default '',\n        PRIMARY KEY (aid),\n        UNIQUE KEY authname (authname)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {blocks} (\n        module varchar(64) DEFAULT '' NOT NULL,\n        delta varchar(32) NOT NULL default '0',\n        theme varchar(255) NOT NULL default '',\n        status tinyint DEFAULT '0' NOT NULL,\n        weight tinyint DEFAULT '0' NOT NULL,\n        region varchar(64) DEFAULT 'left' NOT NULL,\n        custom tinyint DEFAULT '0' NOT NULL,\n        throttle tinyint DEFAULT '0' NOT NULL,\n        visibility tinyint DEFAULT '0' NOT NULL,\n        pages text NOT NULL,\n        title varchar(64) DEFAULT '' NOT NULL\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {boxes} (\n        bid int NOT NULL auto_increment,\n        body longtext,\n        info varchar(128) NOT NULL default '',\n        format int NOT NULL default '0',\n        PRIMARY KEY (bid),\n        UNIQUE KEY info (info)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {cache} (\n        cid varchar(255) NOT NULL default '',\n        data longblob,\n        expire int NOT NULL default '0',\n        created int NOT NULL default '0',\n        headers text,\n        PRIMARY KEY (cid),\n        INDEX expire (expire)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {cache_filter} (\n        cid varchar(255) NOT NULL default '',\n        data longblob,\n        expire int NOT NULL default '0',\n        created int NOT NULL default '0',\n        headers text,\n        PRIMARY KEY (cid),\n        INDEX expire (expire)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {cache_menu} (\n        cid varchar(255) NOT NULL default '',\n        data longblob,\n        expire int NOT NULL default '0',\n        created int NOT NULL default '0',\n        headers text,\n        PRIMARY KEY (cid),\n        INDEX expire (expire)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {cache_page} (\n        cid varchar(255) BINARY NOT NULL default '',\n        data longblob,\n        expire int NOT NULL default '0',\n        created int NOT NULL default '0',\n        headers text,\n        PRIMARY KEY (cid),\n        INDEX expire (expire)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {comments} (\n        cid int NOT NULL auto_increment,\n        pid int NOT NULL default '0',\n        nid int NOT NULL default '0',\n        uid int NOT NULL default '0',\n        subject varchar(64) NOT NULL default '',\n        comment longtext NOT NULL,\n        hostname varchar(128) NOT NULL default '',\n        timestamp int NOT NULL default '0',\n        score mediumint NOT NULL default '0',\n        status tinyint unsigned NOT NULL default '0',\n        format int NOT NULL default '0',\n        thread varchar(255) NOT NULL,\n        users longtext,\n        name varchar(60) default NULL,\n        mail varchar(64) default NULL,\n        homepage varchar(255) default NULL,\n        PRIMARY KEY (cid),\n        KEY lid (nid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {node_comment_statistics} (\n        nid int unsigned NOT NULL auto_increment,\n        last_comment_timestamp int NOT NULL default '0',\n        last_comment_name varchar(60) default NULL,\n        last_comment_uid int NOT NULL default '0',\n        comment_count int unsigned NOT NULL default '0',\n        PRIMARY KEY (nid),\n        KEY node_comment_timestamp (last_comment_timestamp)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {files} (\n        fid int unsigned NOT NULL default 0,\n        nid int unsigned NOT NULL default 0,\n        filename varchar(255) NOT NULL default '',\n        filepath varchar(255) NOT NULL default '',\n        filemime varchar(255) NOT NULL default '',\n        filesize int unsigned NOT NULL default 0,\n        PRIMARY KEY (fid),\n        KEY nid (nid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {file_revisions} (\n        fid int unsigned NOT NULL default 0,\n        vid int unsigned NOT NULL default 0,\n        description varchar(255) NOT NULL default '',\n        list tinyint unsigned NOT NULL default 0,\n        PRIMARY KEY (fid, vid),\n        KEY (vid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {filter_formats} (\n        format int NOT NULL auto_increment,\n        name varchar(255) NOT NULL default '',\n        roles varchar(255) NOT NULL default '',\n        cache tinyint NOT NULL default '0',\n        PRIMARY KEY (format),\n        UNIQUE KEY (name)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {filters} (\n        format int NOT NULL default '0',\n        module varchar(64) NOT NULL default '',\n        delta tinyint DEFAULT '0' NOT NULL,\n        weight tinyint DEFAULT '0' NOT NULL,\n        INDEX (weight)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {flood} (\n        event varchar(64) NOT NULL default '',\n        hostname varchar(128) NOT NULL default '',\n        timestamp int NOT NULL default '0'\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {history} (\n        uid int NOT NULL default '0',\n        nid int NOT NULL default '0',\n        timestamp int NOT NULL default '0',\n        PRIMARY KEY (uid,nid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {menu} (\n        mid int unsigned NOT NULL default '0',\n        pid int unsigned NOT NULL default '0',\n        path varchar(255) NOT NULL default '',\n        title varchar(255) NOT NULL default '',\n        description varchar(255) NOT NULL default '',\n        weight tinyint NOT NULL default '0',\n        type int unsigned NOT NULL default '0',\n        PRIMARY KEY (mid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {node} (\n        nid int unsigned NOT NULL auto_increment,\n        vid int unsigned NOT NULL default '0',\n        type varchar(32) NOT NULL default '',\n        title varchar(128) NOT NULL default '',\n        uid int NOT NULL default '0',\n        status int NOT NULL default '1',\n        created int NOT NULL default '0',\n        changed int NOT NULL default '0',\n        comment int NOT NULL default '0',\n        promote int NOT NULL default '0',\n        moderate int NOT NULL default '0',\n        sticky int NOT NULL default '0',\n        PRIMARY KEY  (nid, vid),\n        UNIQUE KEY vid (vid),\n        KEY node_type (type(4)),\n        KEY node_title_type (title, type(4)),\n        KEY status (status),\n        KEY uid (uid),\n        KEY node_moderate (moderate),\n        KEY node_promote_status (promote, status),\n        KEY node_created (created),\n        KEY node_changed (changed),\n        KEY node_status_type (status, type, nid),\n        KEY nid (nid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {node_access} (\n        nid int unsigned NOT NULL default '0',\n        gid int unsigned NOT NULL default '0',\n        realm varchar(255) NOT NULL default '',\n        grant_view tinyint unsigned NOT NULL default '0',\n        grant_update tinyint unsigned NOT NULL default '0',\n        grant_delete tinyint unsigned NOT NULL default '0',\n        PRIMARY KEY (nid,gid,realm)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {node_revisions} (\n        nid int unsigned NOT NULL,\n        vid int unsigned NOT NULL,\n        uid int NOT NULL default '0',\n        title varchar(128) NOT NULL default '',\n        body longtext NOT NULL,\n        teaser longtext NOT NULL,\n        log longtext NOT NULL,\n        timestamp int NOT NULL default '0',\n        format int NOT NULL default '0',\n        PRIMARY KEY  (vid),\n        KEY nid (nid),\n        KEY uid (uid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {node_type} (\n        type varchar(32) NOT NULL,\n        name varchar(255) NOT NULL default '',\n        module varchar(255) NOT NULL,\n        description mediumtext NOT NULL,\n        help mediumtext NOT NULL,\n        has_title tinyint unsigned NOT NULL,\n        title_label varchar(255) NOT NULL default '',\n        has_body tinyint unsigned NOT NULL,\n        body_label varchar(255) NOT NULL default '',\n        min_word_count smallint unsigned NOT NULL,\n        custom tinyint NOT NULL DEFAULT '0',\n        modified tinyint NOT NULL DEFAULT '0',\n        locked tinyint NOT NULL DEFAULT '0',\n        orig_type varchar(255) NOT NULL default '',\n        PRIMARY KEY (type)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {url_alias} (\n        pid int unsigned NOT NULL auto_increment,\n        src varchar(128) NOT NULL default '',\n        dst varchar(128) NOT NULL default '',\n        PRIMARY KEY (pid),\n        UNIQUE KEY dst (dst),\n        KEY src (src)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {permission} (\n        rid int unsigned NOT NULL default '0',\n        perm longtext,\n        tid int unsigned NOT NULL default '0',\n        KEY rid (rid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {role} (\n        rid int unsigned NOT NULL auto_increment,\n        name varchar(64) NOT NULL default '',\n        PRIMARY KEY (rid),\n        UNIQUE KEY name (name)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {blocks_roles} (\n        module varchar(64) NOT NULL,\n        delta varchar(32) NOT NULL,\n        rid int unsigned NOT NULL,\n        PRIMARY KEY (module, delta, rid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {sessions} (\n        uid int unsigned NOT NULL,\n        sid varchar(64) NOT NULL default '',\n        hostname varchar(128) NOT NULL default '',\n        timestamp int NOT NULL default '0',\n        cache int NOT NULL default '0',\n        session longtext,\n        KEY uid (uid),\n        PRIMARY KEY (sid),\n        KEY timestamp (timestamp)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {sequences} (\n        name varchar(255) NOT NULL default '',\n        id int unsigned NOT NULL default '0',\n        PRIMARY KEY (name)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {node_counter} (\n        nid int NOT NULL default '0',\n        totalcount bigint unsigned NOT NULL default '0',\n        daycount mediumint unsigned NOT NULL default '0',\n        timestamp int unsigned NOT NULL default '0',\n        PRIMARY KEY (nid),\n        KEY totalcount (totalcount),\n        KEY daycount (daycount),\n        KEY timestamp (timestamp)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {system} (\n        filename varchar(255) NOT NULL default '',\n        name varchar(255) NOT NULL default '',\n        type varchar(255) NOT NULL default '',\n        description varchar(255) NOT NULL default '',\n        status int NOT NULL default '0',\n        throttle tinyint DEFAULT '0' NOT NULL,\n        bootstrap int NOT NULL default '0',\n        schema_version smallint NOT NULL default -1,\n        weight int NOT NULL default '0',\n        PRIMARY KEY (filename),\n        KEY (weight)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {term_data} (\n        tid int unsigned NOT NULL auto_increment,\n        vid int unsigned NOT NULL default '0',\n        name varchar(255) NOT NULL default '',\n        description longtext,\n        weight tinyint NOT NULL default '0',\n        PRIMARY KEY (tid),\n        KEY vid (vid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {term_hierarchy} (\n        tid int unsigned NOT NULL default '0',\n        parent int unsigned NOT NULL default '0',\n        KEY tid (tid),\n        KEY parent (parent),\n        PRIMARY KEY (tid, parent)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {term_node} (\n        nid int unsigned NOT NULL default '0',\n        tid int unsigned NOT NULL default '0',\n        KEY nid (nid),\n        KEY tid (tid),\n        PRIMARY KEY (tid,nid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {term_relation} (\n        tid1 int unsigned NOT NULL default '0',\n        tid2 int unsigned NOT NULL default '0',\n        KEY tid1 (tid1),\n        KEY tid2 (tid2)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {term_synonym} (\n        tid int unsigned NOT NULL default '0',\n        name varchar(255) NOT NULL default '',\n        KEY tid (tid),\n        KEY name (name(3))\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {users} (\n        uid int unsigned NOT NULL default '0',\n        name varchar(60) NOT NULL default '',\n        pass varchar(32) NOT NULL default '',\n        mail varchar(64) default '',\n        mode tinyint NOT NULL default '0',\n        sort tinyint default '0',\n        threshold tinyint default '0',\n        theme varchar(255) NOT NULL default '',\n        signature varchar(255) NOT NULL default '',\n        created int NOT NULL default '0',\n        access int NOT NULL default '0',\n        login int NOT NULL default '0',\n        status tinyint NOT NULL default '0',\n        timezone varchar(8) default NULL,\n        language varchar(12) NOT NULL default '',\n        picture varchar(255) NOT NULL DEFAULT '',\n        init varchar(64) default '',\n        data longtext,\n        PRIMARY KEY (uid),\n        UNIQUE KEY name (name),\n        KEY created (created),\n        KEY access (access)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {users_roles} (\n        uid int unsigned NOT NULL default '0',\n        rid int unsigned NOT NULL default '0',\n        PRIMARY KEY (uid, rid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {variable} (\n        name varchar(48) NOT NULL default '',\n        value longtext NOT NULL,\n        PRIMARY KEY (name)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {vocabulary} (\n        vid int unsigned NOT NULL auto_increment,\n        name varchar(255) NOT NULL default '',\n        description longtext,\n        help varchar(255) NOT NULL default '',\n        relations tinyint unsigned NOT NULL default '0',\n        hierarchy tinyint unsigned NOT NULL default '0',\n        multiple tinyint unsigned NOT NULL default '0',\n        required tinyint unsigned NOT NULL default '0',\n        tags tinyint unsigned NOT NULL default '0',\n        module varchar(255) NOT NULL default '',\n        weight tinyint NOT NULL default '0',\n        PRIMARY KEY (vid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {vocabulary_node_types} (\n        vid int unsigned NOT NULL DEFAULT '0',\n        type varchar(32) NOT NULL DEFAULT '',\n        PRIMARY KEY (vid, type)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {watchdog} (\n        wid int NOT NULL auto_increment,\n        uid int NOT NULL default '0',\n        type varchar(16) NOT NULL default '',\n        message longtext NOT NULL,\n        severity tinyint unsigned NOT NULL default '0',\n        link varchar(255) NOT NULL default '',\n        location text NOT NULL,\n        referer varchar(128) NOT NULL default '',\n        hostname varchar(128) NOT NULL default '',\n        timestamp int NOT NULL default '0',\n        PRIMARY KEY (wid),\n        KEY (type)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      break;
    case 'pgsql':

      /* create unsigned types */
      db_query("CREATE DOMAIN int_unsigned integer CHECK (VALUE >= 0)");
      db_query("CREATE DOMAIN smallint_unsigned smallint CHECK (VALUE >= 0)");
      db_query("CREATE DOMAIN bigint_unsigned bigint CHECK (VALUE >= 0)");

      /* create functions */
      db_query('CREATE OR REPLACE FUNCTION "greatest"(numeric, numeric) RETURNS numeric AS
        \'SELECT CASE WHEN (($1 > $2) OR ($2 IS NULL)) THEN $1 ELSE $2 END;\'
        LANGUAGE \'sql\'');
      db_query('CREATE OR REPLACE FUNCTION "greatest"(numeric, numeric, numeric) RETURNS numeric AS
        \'SELECT greatest($1, greatest($2, $3));\'
        LANGUAGE \'sql\'');
      if (!db_result(db_query("SELECT COUNT(*) FROM pg_proc WHERE proname = 'rand'"))) {
        db_query('CREATE OR REPLACE FUNCTION "rand"() RETURNS float AS
          \'SELECT random();\'
          LANGUAGE \'sql\'');
      }
      if (!db_result(db_query("SELECT COUNT(*) FROM pg_proc WHERE proname = 'concat'"))) {
        db_query('CREATE OR REPLACE FUNCTION "concat"(text, text) RETURNS text AS
          \'SELECT $1 || $2;\'
          LANGUAGE \'sql\'');
      }
      db_query('CREATE OR REPLACE FUNCTION "if"(boolean, text, text) RETURNS text AS
        \'SELECT CASE WHEN $1 THEN $2 ELSE $3 END;\'
        LANGUAGE \'sql\'');
      db_query('CREATE OR REPLACE FUNCTION "if"(boolean, integer, integer) RETURNS integer AS
        \'SELECT CASE WHEN $1 THEN $2 ELSE $3 END;\'
        LANGUAGE \'sql\'');

      /* create tables */
      db_query("CREATE TABLE {access} (\n        aid serial,\n        mask varchar(255) NOT NULL default '',\n        type varchar(255) NOT NULL default '',\n        status smallint NOT NULL default '0',\n        PRIMARY KEY (aid)\n      )");
      db_query("CREATE TABLE {authmap} (\n        aid serial CHECK (aid >= 0),\n        uid int NOT NULL default '0',\n        authname varchar(128) NOT NULL default '',\n        module varchar(128) NOT NULL default '',\n        PRIMARY KEY (aid),\n        UNIQUE (authname)\n      )");
      db_query("CREATE TABLE {blocks} (\n        module varchar(64) DEFAULT '' NOT NULL,\n        delta varchar(32) NOT NULL default '0',\n        theme varchar(255) NOT NULL default '',\n        status smallint DEFAULT '0' NOT NULL,\n        weight smallint DEFAULT '0' NOT NULL,\n        region varchar(64) DEFAULT 'left' NOT NULL,\n        custom smallint DEFAULT '0' NOT NULL,\n        throttle smallint DEFAULT '0' NOT NULL,\n        visibility smallint DEFAULT '0' NOT NULL,\n        pages text DEFAULT '' NOT NULL,\n        title varchar(64) DEFAULT '' NOT NULL\n      )");
      db_query("CREATE TABLE {boxes} (\n        bid serial,\n        body text,\n        info varchar(128) NOT NULL default '',\n        format smallint NOT NULL default '0',\n        PRIMARY KEY (bid),\n        UNIQUE (info)\n      )");
      db_query("CREATE TABLE {cache} (\n        cid varchar(255) NOT NULL default '',\n        data bytea,\n        expire int NOT NULL default '0',\n        created int NOT NULL default '0',\n        headers text,\n        PRIMARY KEY (cid)\n      )");
      db_query("CREATE TABLE {cache_filter} (\n        cid varchar(255) NOT NULL default '',\n        data bytea,\n        expire int NOT NULL default '0',\n        created int NOT NULL default '0',\n        headers text,\n        PRIMARY KEY (cid)\n      )");
      db_query("CREATE TABLE {cache_menu} (\n        cid varchar(255) NOT NULL default '',\n        data bytea,\n        expire int NOT NULL default '0',\n        created int NOT NULL default '0',\n        headers text,\n        PRIMARY KEY (cid)\n      )");
      db_query("CREATE TABLE {cache_page} (\n        cid varchar(255) NOT NULL default '',\n        data bytea,\n        expire int NOT NULL default '0',\n        created int NOT NULL default '0',\n        headers text,\n        PRIMARY KEY (cid)\n      )");
      db_query("CREATE INDEX {cache}_expire_idx ON {cache} (expire)");
      db_query("CREATE INDEX {cache_filter}_expire_idx ON {cache_filter} (expire)");
      db_query("CREATE INDEX {cache_menu}_expire_idx ON {cache_menu} (expire)");
      db_query("CREATE INDEX {cache_page}_expire_idx ON {cache_page} (expire)");
      db_query("CREATE TABLE {comments} (\n        cid serial,\n        pid int NOT NULL default '0',\n        nid int NOT NULL default '0',\n        uid int NOT NULL default '0',\n        subject varchar(64) NOT NULL default '',\n        comment text NOT NULL,\n        hostname varchar(128) NOT NULL default '',\n        timestamp int NOT NULL default '0',\n        score int NOT NULL default '0',\n        status smallint_unsigned NOT NULL default '0',\n        format smallint NOT NULL default '0',\n        thread varchar(255) NOT NULL,\n        users text,\n        name varchar(60) default NULL,\n        mail varchar(64) default NULL,\n        homepage varchar(255) default NULL,\n        PRIMARY KEY (cid)\n      )");
      db_query("CREATE INDEX {comments}_nid_idx ON {comments} (nid)");
      db_query("CREATE TABLE {node_comment_statistics} (\n        nid serial CHECK (nid >= 0),\n        last_comment_timestamp int NOT NULL default '0',\n        last_comment_name varchar(60) default NULL,\n        last_comment_uid int NOT NULL default '0',\n        comment_count int_unsigned NOT NULL default '0',\n        PRIMARY KEY (nid)\n      )");
      db_query("CREATE INDEX {node_comment_statistics}_node_comment_timestamp_idx ON {node_comment_statistics} (last_comment_timestamp)");
      db_query("CREATE TABLE {files} (\n        fid serial CHECK (fid >= 0),\n        nid int_unsigned NOT NULL default 0,\n        filename varchar(255) NOT NULL default '',\n        filepath varchar(255) NOT NULL default '',\n        filemime varchar(255) NOT NULL default '',\n        filesize int_unsigned NOT NULL default 0,\n        PRIMARY KEY (fid)\n      )");
      db_query("CREATE INDEX {files}_nid_idx ON {files} (nid)");
      db_query("CREATE TABLE {file_revisions} (\n        fid int_unsigned NOT NULL default 0,\n        vid int_unsigned NOT NULL default 0,\n        description varchar(255) NOT NULL default '',\n        list smallint_unsigned NOT NULL default 0,\n        PRIMARY KEY (fid, vid)\n      )");
      db_query("CREATE INDEX {file_revisions}_vid_idx ON {file_revisions} (vid)");
      db_query("CREATE TABLE {filter_formats} (\n        format serial,\n        name varchar(255) NOT NULL default '',\n        roles varchar(255) NOT NULL default '',\n        cache smallint NOT NULL default '0',\n        PRIMARY KEY (format),\n        UNIQUE (name)\n      )");
      db_query("CREATE TABLE {filters} (\n        format int NOT NULL default '0',\n        module varchar(64) NOT NULL default '',\n        delta smallint DEFAULT '0' NOT NULL,\n        weight smallint DEFAULT '0' NOT NULL\n      )");
      db_query("CREATE INDEX {filters}_weight_idx ON {filters} (weight)");
      db_query("CREATE TABLE {flood} (\n        event varchar(64) NOT NULL default '',\n        hostname varchar(128) NOT NULL default '',\n        timestamp int NOT NULL default '0'\n      )");
      db_query("CREATE TABLE {history} (\n        uid int NOT NULL default '0',\n        nid int NOT NULL default '0',\n        timestamp int NOT NULL default '0',\n        PRIMARY KEY (uid,nid)\n      )");
      db_query("CREATE TABLE {menu} (\n        mid serial CHECK (mid >= 0),\n        pid int_unsigned NOT NULL default '0',\n        path varchar(255) NOT NULL default '',\n        title varchar(255) NOT NULL default '',\n        description varchar(255) NOT NULL default '',\n        weight smallint NOT NULL default '0',\n        type int_unsigned NOT NULL default '0',\n        PRIMARY KEY (mid)\n      )");
      db_query("ALTER SEQUENCE {menu}_mid_seq MINVALUE 2 RESTART 2");
      db_query("CREATE TABLE {node} (\n        nid serial CHECK (nid >= 0),\n        vid int_unsigned NOT NULL default '0',\n        type varchar(32) NOT NULL default '',\n        title varchar(128) NOT NULL default '',\n        uid int NOT NULL default '0',\n        status int NOT NULL default '1',\n        created int NOT NULL default '0',\n        changed int NOT NULL default '0',\n        comment int NOT NULL default '0',\n        promote int NOT NULL default '0',\n        moderate int NOT NULL default '0',\n        sticky int NOT NULL default '0',\n        PRIMARY KEY (nid, vid),\n        UNIQUE (vid)\n      )");
      db_query("CREATE INDEX {node}_node_type_idx ON {node} (substr (type, 1, 4))");
      db_query("CREATE INDEX {node}_node_title_type_idx ON {node} (title, substr(type, 1, 4))");
      db_query("CREATE INDEX {node}_status_idx ON {node} (status)");
      db_query("CREATE INDEX {node}_uid_idx ON {node} (uid)");
      db_query("CREATE INDEX {node}_node_moderate_idx ON {node} (moderate)");
      db_query("CREATE INDEX {node}_node_promote_status_idx ON {node} (promote, status)");
      db_query("CREATE INDEX {node}_node_created_idx ON {node} (created)");
      db_query("CREATE INDEX {node}_node_changed_idx ON {node} (changed)");
      db_query("CREATE INDEX {node}_node_status_type_idx ON {node} (status, type, nid)");
      db_query("CREATE INDEX {node}_nid_idx ON {node} (nid)");
      db_query("CREATE TABLE {node_access} (\n        nid int_unsigned NOT NULL default '0',\n        gid int_unsigned NOT NULL default '0',\n        realm varchar(255) NOT NULL default '',\n        grant_view smallint_unsigned NOT NULL default '0',\n        grant_update smallint_unsigned NOT NULL default '0',\n        grant_delete smallint_unsigned NOT NULL default '0',\n        PRIMARY KEY (nid,gid,realm)\n      )");
      db_query("CREATE TABLE {node_revisions} (\n        nid int_unsigned NOT NULL,\n        vid serial CHECK (vid >= 0),\n        uid int NOT NULL default '0',\n        title varchar(128) NOT NULL default '',\n        body text NOT NULL default '',\n        teaser text NOT NULL default '',\n        log text NOT NULL default '',\n        timestamp int NOT NULL default '0',\n        format int NOT NULL default '0',\n        PRIMARY KEY (vid)\n      )");
      db_query("CREATE INDEX {node_revisions}_nid_idx ON {node_revisions} (nid)");
      db_query("CREATE INDEX {node_revisions}_uid_idx ON {node_revisions} (uid)");
      db_query("CREATE TABLE {node_type} (\n        type varchar(32) NOT NULL,\n        name varchar(255) NOT NULL default '',\n        module varchar(255) NOT NULL,\n        description text NOT NULL,\n        help text NOT NULL,\n        has_title smallint_unsigned NOT NULL,\n        title_label varchar(255) NOT NULL default '',\n        has_body smallint_unsigned NOT NULL,\n        body_label varchar(255) NOT NULL default '',\n        min_word_count smallint_unsigned NOT NULL,\n        custom smallint NOT NULL DEFAULT '0',\n        modified smallint NOT NULL DEFAULT '0',\n        locked smallint NOT NULL DEFAULT '0',\n        orig_type varchar(255) NOT NULL default '',\n        PRIMARY KEY (type)\n      )");
      db_query("CREATE TABLE {url_alias} (\n        pid serial CHECK (pid >= 0),\n        src varchar(128) NOT NULL default '',\n        dst varchar(128) NOT NULL default '',\n        PRIMARY KEY (pid),\n        UNIQUE (dst)\n      )");
      db_query("CREATE INDEX {url_alias}_src_idx ON {url_alias} (src)");
      db_query("CREATE TABLE {permission} (\n        rid int_unsigned NOT NULL default '0',\n        perm text,\n        tid int_unsigned NOT NULL default '0'\n      )");
      db_query("CREATE INDEX {permission}_rid_idx ON {permission} (rid)");
      db_query("CREATE TABLE {role} (\n        rid serial CHECK (rid >= 0),\n        name varchar(64) NOT NULL default '',\n        PRIMARY KEY (rid),\n        UNIQUE (name)\n      )");
      db_query("SELECT setval('{role}_rid_seq'," . max(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID) . ")");
      db_query("CREATE TABLE {blocks_roles} (\n        module varchar(64) NOT NULL,\n        delta varchar(32) NOT NULL,\n        rid int_unsigned NOT NULL,\n        PRIMARY KEY (module, delta, rid)\n      )");
      db_query("CREATE TABLE {sessions} (\n        uid int_unsigned NOT NULL,\n        sid varchar(64) NOT NULL default '',\n        hostname varchar(128) NOT NULL default '',\n        timestamp int NOT NULL default '0',\n        cache int NOT NULL default '0',\n        session text,\n        PRIMARY KEY (sid)\n      )");
      db_query("CREATE INDEX {sessions}_uid_idx ON {sessions} (uid)");
      db_query("CREATE INDEX {sessions}_timestamp_idx ON {sessions} (timestamp)");

      /* Only used for MySQL
         db_query("CREATE TABLE {sequences} (
           name varchar(255) NOT NULL default '',
           id int_unsigned NOT NULL default '0',
           PRIMARY KEY (name)
         )"); */
      db_query("CREATE TABLE {node_counter} (\n        nid int NOT NULL default '0',\n        totalcount bigint_unsigned NOT NULL default '0',\n        daycount int_unsigned NOT NULL default '0',\n        timestamp int_unsigned NOT NULL default '0',\n        PRIMARY KEY (nid)\n      )");
      db_query("CREATE INDEX {node_counter}_totalcount_idx ON {node_counter} (totalcount)");
      db_query("CREATE INDEX {node_counter}_daycount_idx ON {node_counter} (daycount)");
      db_query("CREATE INDEX {node_counter}_timestamp_idx ON {node_counter} (timestamp)");
      db_query("CREATE TABLE {system} (\n        filename varchar(255) NOT NULL default '',\n        name varchar(255) NOT NULL default '',\n        type varchar(255) NOT NULL default '',\n        description varchar(255) NOT NULL default '',\n        status int NOT NULL default '0',\n        throttle smallint DEFAULT '0' NOT NULL,\n        bootstrap int NOT NULL default '0',\n        schema_version smallint NOT NULL default -1,\n        weight int NOT NULL default '0',\n        PRIMARY KEY (filename)\n      )");
      db_query("CREATE INDEX {system}_weight_idx ON {system} (weight)");
      db_query("CREATE TABLE {term_data} (\n        tid serial CHECK (tid >= 0),\n        vid int_unsigned NOT NULL default '0',\n        name varchar(255) NOT NULL default '',\n        description text,\n        weight smallint NOT NULL default '0',\n        PRIMARY KEY (tid)\n      )");
      db_query("CREATE INDEX {term_data}_vid_idx ON {term_data} (vid)");
      db_query("CREATE TABLE {term_hierarchy} (\n        tid int_unsigned NOT NULL default '0',\n        parent int_unsigned NOT NULL default '0',\n        PRIMARY KEY (tid, parent)\n      )");
      db_query("CREATE INDEX {term_hierarchy}_tid_idx ON {term_hierarchy} (tid)");
      db_query("CREATE INDEX {term_hierarchy}_parent_idx ON {term_hierarchy} (parent)");
      db_query("CREATE TABLE {term_node} (\n        nid int_unsigned NOT NULL default '0',\n        tid int_unsigned NOT NULL default '0',\n        PRIMARY KEY (tid,nid)\n      )");
      db_query("CREATE INDEX {term_node}_nid_idx ON {term_node} (nid)");
      db_query("CREATE INDEX {term_node}_tid_idx ON {term_node} (tid)");
      db_query("CREATE TABLE {term_relation} (\n        tid1 int_unsigned NOT NULL default '0',\n        tid2 int_unsigned NOT NULL default '0'\n      )");
      db_query("CREATE INDEX {term_relation}_tid1_idx ON {term_relation} (tid1)");
      db_query("CREATE INDEX {term_relation}_tid2_idx ON {term_relation} (tid2)");
      db_query("CREATE TABLE {term_synonym} (\n        tid int_unsigned NOT NULL default '0',\n        name varchar(255) NOT NULL default ''\n      )");
      db_query("CREATE INDEX {term_synonym}_tid_idx ON {term_synonym} (tid)");
      db_query("CREATE INDEX {term_synonym}_name_idx ON {term_synonym} (substr(name, 1, 3))");
      db_query("CREATE TABLE {users} (\n        uid serial CHECK (uid >= 0),\n        name varchar(60) NOT NULL default '',\n        pass varchar(32) NOT NULL default '',\n        mail varchar(64) default '',\n        mode smallint NOT NULL default '0',\n        sort smallint default '0',\n        threshold smallint default '0',\n        theme varchar(255) NOT NULL default '',\n        signature varchar(255) NOT NULL default '',\n        created int NOT NULL default '0',\n        access int NOT NULL default '0',\n        login int NOT NULL default '0',\n        status smallint NOT NULL default '0',\n        timezone varchar(8) default NULL,\n        language varchar(12) NOT NULL default '',\n        picture varchar(255) NOT NULL DEFAULT '',\n        init varchar(64) default '',\n        data text,\n        PRIMARY KEY (uid),\n        UNIQUE (name)\n      )");
      db_query("CREATE INDEX {users}_access_idx ON {users} (access)");
      db_query("CREATE INDEX {users}_created_idx ON {users} (created)");
      db_query("CREATE TABLE {users_roles} (\n        uid int_unsigned NOT NULL default '0',\n        rid int_unsigned NOT NULL default '0',\n        PRIMARY KEY (uid, rid)\n      )");
      db_query("CREATE TABLE {variable} (\n        name varchar(48) NOT NULL default '',\n        value text NOT NULL,\n        PRIMARY KEY (name)\n      )");
      db_query("CREATE TABLE {vocabulary} (\n        vid serial CHECK (vid >= 0),\n        name varchar(255) NOT NULL default '',\n        description text,\n        help varchar(255) NOT NULL default '',\n        relations smallint_unsigned NOT NULL default '0',\n        hierarchy smallint_unsigned NOT NULL default '0',\n        multiple smallint_unsigned NOT NULL default '0',\n        required smallint_unsigned NOT NULL default '0',\n        tags smallint_unsigned NOT NULL default '0',\n        module varchar(255) NOT NULL default '',\n        weight smallint NOT NULL default '0',\n        PRIMARY KEY (vid)\n      )");
      db_query("CREATE TABLE {vocabulary_node_types} (\n        vid int_unsigned NOT NULL DEFAULT '0',\n        type varchar(32) NOT NULL DEFAULT '',\n        PRIMARY KEY (vid, type)\n      )");
      db_query("CREATE TABLE {watchdog} (\n        wid serial,\n        uid int NOT NULL default '0',\n        type varchar(16) NOT NULL default '',\n        message text NOT NULL,\n        severity smallint_unsigned NOT NULL default '0',\n        link varchar(255) NOT NULL default '',\n        location text NOT NULL default '',\n        referer varchar(128) NOT NULL default '',\n        hostname varchar(128) NOT NULL default '',\n        timestamp int NOT NULL default '0',\n        PRIMARY KEY (wid)\n      )");
      db_query("CREATE INDEX {watchdog}_type_idx ON {watchdog} (type)");
      break;
  }
  db_query("INSERT INTO {system} (filename, name, type, description, status, throttle, bootstrap, schema_version) VALUES ('themes/engines/phptemplate/phptemplate.engine', 'phptemplate', 'theme_engine', '', 1, 0, 0, 0)");
  db_query("INSERT INTO {system} (filename, name, type, description, status, throttle, bootstrap, schema_version) VALUES ('themes/garland/page.tpl.php', 'garland', 'theme', 'themes/engines/phptemplate/phptemplate.engine', 1, 0, 0, 0)");
  db_query("INSERT INTO {users} (uid,name,mail) VALUES(0,'','')");
  db_query("INSERT INTO {role} (rid, name) VALUES (" . DRUPAL_ANONYMOUS_RID . ", 'anonymous user')");
  db_query("INSERT INTO {role} (rid, name) VALUES (" . DRUPAL_AUTHENTICATED_RID . ", 'authenticated user')");
  db_query("INSERT INTO {permission} VALUES (1,'access content',0)");
  db_query("INSERT INTO {permission} VALUES (2,'access comments, access content, post comments, post comments without approval',0)");
  db_query("INSERT INTO {variable} (name,value) VALUES('theme_default', 's:7:\"garland\";')");
  db_query("INSERT INTO {blocks} (module,delta,theme,status,pages) VALUES('user', 0, 'garland', 1, '')");
  db_query("INSERT INTO {blocks} (module,delta,theme,status,pages) VALUES('user', 1, 'garland', 1, '')");
  db_query("INSERT INTO {node_access} VALUES (0, 0, 'all', 1, 0, 0)");
  db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('Filtered HTML',',1,2,',1)");
  db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('PHP code','',0)");
  db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('Full HTML','',1)");
  db_query("INSERT INTO {filters} VALUES (1,'filter',3,0)");
  db_query("INSERT INTO {filters} VALUES (1,'filter',0,1)");
  db_query("INSERT INTO {filters} VALUES (1,'filter',2,2)");
  db_query("INSERT INTO {filters} VALUES (2,'filter',1,0)");
  db_query("INSERT INTO {filters} VALUES (3,'filter',3,0)");
  db_query("INSERT INTO {filters} VALUES (3,'filter',2,1)");
  db_query("INSERT INTO {variable} (name,value) VALUES ('filter_html_1','i:1;')");
  db_query("INSERT INTO {variable} (name, value) VALUES ('node_options_forum', '%s')", 'a:1:{i:0;s:6:"status";}');
  db_query("INSERT INTO {menu} (mid, pid, path, title, description, weight, type) VALUES (2, 0, '', 'Primary links', '', 0, 115)");
  db_query("INSERT INTO {variable} VALUES ('menu_primary_menu', 'i:2;')");
  db_query("INSERT INTO {variable} VALUES ('menu_secondary_menu', 'i:2;')");
}