Index: install.php
===================================================================
RCS file: /cvs/drupal/drupal/install.php,v
retrieving revision 1.41
diff -u -F^f -r1.41 install.php
--- install.php	13 Apr 2007 08:56:57 -0000	1.41
+++ install.php	3 May 2007 23:23:26 -0000
@@ -39,12 +39,26 @@ function install_main() {
   }
 
   // Load module basics (needed for hook invokes).
+  // We load all modules that either are required during installation time
+  // or have models that need to be created
   include_once './includes/module.inc';
   $module_list['system']['filename'] = 'modules/system/system.module';
   $module_list['filter']['filename'] = 'modules/filter/filter.module';
+  $module_list['block']['filename'] = 'modules/block/block.module';
+  $module_list['user']['filename'] = 'modules/user/user.module';
+  $module_list['node']['filename'] = 'modules/node/node.module';
+  $module_list['comment']['filename'] = 'modules/comment/comment.module';
+  $module_list['taxonomy']['filename'] = 'modules/taxonomy/taxonomy.module';
   module_list(TRUE, FALSE, FALSE, $module_list);
   drupal_load('module', 'system');
   drupal_load('module', 'filter');
+  drupal_load('module', 'block');
+  drupal_load('module', 'user');
+  drupal_load('module', 'node');
+  drupal_load('module', 'comment');
+  drupal_load('module', 'taxonomy');
+  drupal_load('module', 'system');
+  drupal_load('module', 'filter');
 
   // Decide which profile to use.
   if (!empty($_GET['profile'])) {
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.638
diff -u -F^f -r1.638 common.inc
--- includes/common.inc	1 May 2007 06:53:02 -0000	1.638
+++ includes/common.inc	3 May 2007 23:23:27 -0000
@@ -2495,6 +2495,121 @@ function drupal_common_themes() {
 }
 
 /**
+ * Get a schema defintion.
+ *
+ * A drupal schema definition is a representation of a data structure (a table).
+ * Schemas are defined in hook_schema().
+ * 
+ * The following keys are processed during table creation:
+ *  - 'table': The table name. Defaults to the schema's name.
+ *  - 'fields': An associative array ('fieldname' => details) that describes the schema's fields.
+ *     The following keys are available:
+ *       - 'type': The generic datatype: 'varchar', 'int', 'float', 'numeric', 'text', 'blob' or 'datetime'.
+ *       - 'size': The data size: 'tiny', 'small', 'medium', 'normal', 'big'.
+ *         This decides which engine-specific datatype is used (e.g. TINYINT vs. INT). 
+ *         If not set, 'normal' is used (which would expand to INT resp. TEXT resp. BLOB). 
+ *         Not all sizes are available for all data types. See db_type_map() for possible combinations.
+ *       - 'not null': If true, no NULL values will be allowed. Defaults to false.
+ *       - 'default': The default value.
+ *     The following keys are only available for some types:
+ *       - 'length': The max. length (character types only)
+ *       - 'disp_width': The display width ('int' only, not supported by all database engines)
+ *       - 'unsigned': 'int', 'float' and 'numeric' only
+ *       - 'auto_increment': 'int' only
+ *       - 'precision', 'scale': 'numeric' only. They can only be used together.
+ *       All options apart from 'type' are optional.
+ *  - 'primary key': An array of (one or more) field names that form the primary key
+ *  - 'unique key': An array of the form 'key_name' => array('field1' [, 'field2' [, 'field3']])
+ *  - 'indexes': An array of the form 'index_name' => array('field1' [, 'field2' [, 'field3']])
+ * 
+ * @param $name The name of the schema.
+ */
+  
+function drupal_get_schema($name) {
+  $schemas = drupal_load_schemas();
+  
+  if (isset($schemas[$name])) { 
+    return $schemas[$name];
+  }
+  else {
+    return FALSE;
+  }
+}
+
+/**
+ * Load all schema definitions.
+ * 
+ * @param $rebuild
+ *   If true, the schema will be rebuilt instead of retreived from the cache.
+ * @return
+ *   An array containing all schema definitions (processed and altered).
+ */
+function drupal_load_schemas($rebuild = FALSE) {
+  static $schemas = array();
+  
+  if (!$rebuild && !empty($schemas)) {
+    return $schemas;
+  }
+  
+  if (!$rebuild && $cached = cache_get('schemas')) {
+    $schemas = $cached->data;
+    return $schemas;
+  }
+  
+  // Rebuild the schema cache.
+  $schemas = module_invoke_all('schema');
+  
+  drupal_process_schemas($schemas);
+  drupal_alter('schema', $schemas);
+  
+  // cache_set() is not available during installation.
+  if (function_exists('cache_set')) {
+    cache_set('schemas', $schemas);
+  }
+  
+  return $schemas;
+}
+
+/**
+ * Set default/required properties for a set of schemas.
+ * 
+ * @param $schemas
+ *   An array containing schema definitions, as returned in hook_schema.
+ */
+function drupal_process_schemas(&$schemas) {
+  if (empty($schemas)) {
+    return FALSE;
+  }
+  
+  foreach ($schemas as $name => $schema) {
+    // Set some default schema properties.
+    $defaults = array(
+      'name'         => $name, 
+      'table'        => $name,
+    );
+    $schemas[$name] = array_merge($defaults, $schema);
+    drupal_process_fields($schemas[$name]['fields']);
+  }
+}
+
+/**
+ * Set default/required properties on schema fields.
+ * 
+ * @param $fields 
+ *   An array of field descriptions
+ */
+function drupal_process_fields(&$fields) {
+  foreach ($fields as $name => $field) {
+    
+    if (!isset($field['size'])) {
+      $fields[$name]['size'] = 'normal';
+    }
+    
+  }
+}
+
+
+/**
  * Parse Drupal info file format.
  *
  * Files should use an ini-like format to specify values.
Index: includes/database.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database.inc,v
retrieving revision 1.67
diff -u -F^f -r1.67 database.inc
--- includes/database.inc	13 Apr 2007 08:56:57 -0000	1.67
+++ includes/database.inc	3 May 2007 23:23:28 -0000
@@ -309,6 +309,20 @@ function db_escape_table($string) {
 }
 
 /**
+ * Create tables from schema definitions.
+ * You should pass the unprocessed and unaltered schema definitions to this function, 
+ * as returned by hook_schema().
+ */
+function db_create_schemas($schemas) {
+  // Set missing required values
+  drupal_process_schemas($schemas);
+  
+  foreach ($schemas as $schema) {
+    db_create_table($schema);
+  }
+}
+
+/**
  * @} End of "defgroup database".
  */
 
Index: includes/database.mysql.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database.mysql.inc,v
retrieving revision 1.70
diff -u -F^f -r1.70 database.mysql.inc
--- includes/database.mysql.inc	21 Apr 2007 18:08:41 -0000	1.70
+++ includes/database.mysql.inc	3 May 2007 23:23:28 -0000
@@ -445,6 +445,255 @@ function db_distinct_field($table, $fiel
   return preg_replace('/(SELECT.*)(?:'. $table .'\.|\s)(?<!DISTINCT\()(?<!DISTINCT\('. $table .'\.)'. $field .'(.*FROM )/AUsi', '\1 '. $field_to_select .'\2', $query);
 }
 
+
+ /**
+ * Create a new table from a drupal schema definition.
+ * 
+ * @param $schema A valid drupal schema definition array
+ * @param $execute If false the SQL query string is returned instead of executed (defaults to true)
+ * @return The return value of db_query, or the query string if $execute is false
+ */
+function db_create_table($schema, $execute = TRUE) {
+  
+  if (empty($schema['mysql_suffix'])) {
+    $schema['mysql_suffix'] = "/*!40100 DEFAULT CHARACTER SET UTF8 */";
+  }
+  
+  $query = "CREATE TABLE {" . $schema['table'] . "} (\n";
+  
+  // Add the SQL statement for each field.
+  foreach ($schema['fields'] as $name => $field) { 
+    $query .= _db_create_field_sql($name, db_process_field($field)) . ", \n";
+  } 
+  
+  // Process keys & indexes.
+  if (!empty($schema['primary key']))
+    $query .= " PRIMARY KEY (" . implode(', ', $schema['primary key']) . "), \n";
+  
+  if (!empty($schema['unique keys'])) {
+    foreach ($schema['unique keys'] as $key => $fields)
+      $query .= " UNIQUE KEY $key (" . implode(', ', $fields) . "), \n";
+  } 
+  
+  if (!empty($schema['indexes'])) {
+    foreach ($schema['indexes'] as $index => $fields)
+      $query .= " INDEX $index (" . implode(', ', $fields) . "), \n";
+  } 
+  
+  $query = substr($query, 0, -3) . "\n) ";
+  
+  $query .= $schema['mysql_suffix'];
+
+  if ($execute)
+    return db_query($query);
+  else
+    return $query;
+} 
+
+/**
+ * Set database-engine specific properties for a field.
+ * 
+ * @param $field 
+ *   A field description array, as specified in the data model documentation.
+ */
+function db_process_field(&$field) {
+
+  // Set the correct database-engine specific datatype.
+  if (!isset($field['mysql_type'])) {
+    $map = db_type_map();
+    $field['mysql_type'] = $map[$field['type'] .":". $field['size']];
+  }
+  
+  if ($field['type'] == 'serial') {
+    $field['auto_increment'] = true;
+  }
+  
+  return $field; 
+}
+
+/**
+ * Create a SQL string for a field to be used in table creation or alteration.
+ * 
+ * Before passing a field out of a schema definition into this function it has 
+ * to be processed by db_process_field.
+ * 
+ * @param $name 
+ *    Name of the field 
+ * @param $details 
+ *    The field properties. At least $details['dbtype'] has to be set by now.
+ *    Aditional properties are 'length', 'unsigned', 'not null', 'auto_increment', 'default'
+ */
+function _db_create_field_sql($name, $details) {
+  $query = "`" . $name . "` " . $details['mysql_type'];  
+  
+  if (isset($details['length']) || isset($details['disp_width'])) {
+    $value = isset($details['length']) ? $details['length'] : $details['disp_width'];
+    $query .= "($value) ";
+  }
+  elseif (isset($details['precision']) && isset($details['scale'])) {
+    $query .= "(". $details['scale'] .", ". $details['precision'] . ")";
+  }
+  
+  if (!empty($details['unsigned'])) {
+    $query .= " unsigned ";
+  }
+
+  if (!empty($details['not null'])) {
+    $query .= " NOT NULL ";
+  }
+  
+  if (!empty($details['auto_increment'])) {
+    $query .= " auto_increment ";
+  }
+    
+  if (isset($details['default'])) {
+    if (is_string($details['default'])) {
+      $details['default'] = "'".$details['default']."'";
+    }
+    $query .= " DEFAULT " . $details['default'] . " ";
+  }
+  
+  if (empty($details['not null']) && !isset($details['default'])) {
+    $query .= " DEFAULT NULL ";
+  }
+  
+  return substr($query, 0, -1);
+}
+
+/**
+ * This maps a generic data type in combination with its data size
+ * to the engine-specific data type.
+ */
+function db_type_map() {
+  $map = array(
+    'varchar:normal'  => 'VARCHAR',
+    
+    'text:tiny'       => 'SMALLTEXT',
+    'text:small'      => 'SMALLTEXT',
+    'text:medium'     => 'MEDIUMTEXT',
+    'text:big'        => 'LONGTEXT',
+    'text:normal'     => 'TEXT',
+
+    'serial:tiny'     => 'TINYINT',
+    'serial:small'    => 'SMALLINT',
+    'serial:medium'   => 'MEDIUMINT',
+    'serial:big'      => 'BIGINT',
+    'serial:normal'   => 'INT',
+
+    'int:tiny'        => 'TINYINT',
+    'int:small'       => 'SMALLINT',
+    'int:medium'      => 'MEDIUMINT',
+    'int:big'         => 'BIGINT',
+    'int:normal'      => 'INT',
+
+    'float:tiny'      => 'FLOAT',
+    'float:small'     => 'FLOAT',
+    'float:medium'    => 'FLOAT',
+    'float:big'       => 'DOUBLE',
+    'float:normal'    => 'FLOAT',
+    
+    'numeric:normal'  => 'NUMERIC',
+    
+    'blob:normal'     => 'BLOB',
+    'blob:big'        => 'LONGBLOB',
+
+    'datetime:normal' => 'DATETIME',
+  );
+  return $map;
+}
+
+/**
+* Drop table.
+* 
+* @param string $table 
+*   The table to be dropped.
+*/
+function db_drop_table($table) {
+  return db_query("DROP TABLE {". $table ."}");
+} 
+
+/**
+* Create index.
+* 
+* @param  $table 
+*   The table to be altered.
+* @param  $name 
+*   The index's name.
+* @param  $columns 
+*   An array of column names
+*/
+function db_create_index($table, $name, $columns) {
+  $query = 'ALTER TABLE {'. $table .'} ADD INDEX '. $name .' (';
+  
+  foreach ($columns as $current) {
+    $query .= $current . ', ';
+  }
+  
+  $query = substr($query, 0, -2) . ')';
+  
+  return db_query($query);
+} 
+
+/**
+* Drop index.
+* 
+* @param string $table 
+*   The table to be altered.
+* @param string $name 
+*   Name of the index to be dropped.
+*/
+function db_drop_index($table, $name) {
+  return db_query('ALTER TABLE '. $table .' DROP INDEX '. $name);
+} 
+
+/**
+* Adds a new field to a table.
+* 
+* @param $table 
+*   Name of the table to be altered.
+* @param $field 
+*   Name of the field to be added.
+* @param $info
+*   The field information array, as taken from a schema definition
+*/
+function db_add_field($table, $field, $info) {
+  $query = 'ALTER TABLE {'. $table .'} ADD '. $field .' ';
+  $query .= _create_field_sql($field, $info);
+  return db_query($query);
+} 
+
+/**
+* Drop field.
+* 
+* @param string $table 
+*   The table to be altered.
+* @param string $field 
+*   The field to be dropped.
+*/
+function db_drop_field($table, $field) {
+  return db_query('ALTER TABLE {'. $table .'} DROP '. $field);
+} 
+
+/**
+ * Set default value for $column.
+ *
+ * @param $table
+ * @param $field
+ *   The field to be altered.
+ * @param $default
+ *   Default value to be set.
+ */
+function db_field_set_default($table, $field, $default) {
+  if ($default == NUll) {
+    $default = 'NULL';
+  }
+  else {
+    $default = is_string($default) ? "'$default'" : $default;
+  }
+  
+  return db_query("ALTER TABLE {". $table ."} ALTER COLUMN ". $field ." SET DEFAULT ". $default);
+}
+
 /**
  * @} End of "ingroup database".
  */
Index: modules/aggregator/aggregator.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.install,v
retrieving revision 1.8
diff -u -F^f -r1.8 aggregator.install
--- modules/aggregator/aggregator.install	26 Sep 2006 14:19:00 -0000	1.8
+++ modules/aggregator/aggregator.install	3 May 2007 23:23:28 -0000
@@ -5,115 +5,10 @@
  * Implementation of hook_install().
  */
 function aggregator_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE {aggregator_category} (
-        cid int NOT NULL auto_increment,
-        title varchar(255) NOT NULL default '',
-        description longtext NOT NULL,
-        block tinyint NOT NULL default '0',
-        PRIMARY KEY (cid),
-        UNIQUE KEY title (title)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {aggregator_category_feed} (
-        fid int NOT NULL default '0',
-        cid int NOT NULL default '0',
-        PRIMARY KEY (fid,cid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {aggregator_category_item} (
-        iid int NOT NULL default '0',
-        cid int NOT NULL default '0',
-        PRIMARY KEY (iid,cid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {aggregator_feed} (
-        fid int NOT NULL auto_increment,
-        title varchar(255) NOT NULL default '',
-        url varchar(255) NOT NULL default '',
-        refresh int NOT NULL default '0',
-        checked int NOT NULL default '0',
-        link varchar(255) NOT NULL default '',
-        description longtext NOT NULL,
-        image longtext NOT NULL,
-        etag varchar(255) NOT NULL default '',
-        modified int NOT NULL default '0',
-        block tinyint NOT NULL default '0',
-        PRIMARY KEY (fid),
-        UNIQUE KEY link (url),
-        UNIQUE KEY title (title)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {aggregator_item} (
-        iid int NOT NULL auto_increment,
-        fid int NOT NULL default '0',
-        title varchar(255) NOT NULL default '',
-        link varchar(255) NOT NULL default '',
-        author varchar(255) NOT NULL default '',
-        description longtext NOT NULL,
-        timestamp int default NULL,
-        guid varchar(255),
-        PRIMARY KEY (iid),
-        KEY fid (fid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      break;
-    case 'pgsql':
-      db_query("CREATE TABLE {aggregator_category} (
-        cid serial,
-        title varchar(255) NOT NULL default '',
-        description text NOT NULL,
-        block smallint NOT NULL default '0',
-        PRIMARY KEY (cid),
-        UNIQUE (title)
-      )");
-
-      db_query("CREATE TABLE {aggregator_category_feed} (
-        fid int NOT NULL default '0',
-        cid int NOT NULL default '0',
-        PRIMARY KEY (fid,cid)
-      )");
-
-      db_query("CREATE TABLE {aggregator_category_item} (
-        iid int NOT NULL default '0',
-        cid int NOT NULL default '0',
-        PRIMARY KEY (iid,cid)
-      )");
-
-      db_query("CREATE TABLE {aggregator_feed} (
-        fid serial,
-        title varchar(255) NOT NULL default '',
-        url varchar(255) NOT NULL default '',
-        refresh int NOT NULL default '0',
-        checked int NOT NULL default '0',
-        link varchar(255) NOT NULL default '',
-        description text NOT NULL default '',
-        image text NOT NULL default '',
-        etag varchar(255) NOT NULL default '',
-        modified int NOT NULL default '0',
-        block smallint NOT NULL default '0',
-        PRIMARY KEY (fid),
-        UNIQUE (url),
-        UNIQUE (title)
-      )");
-
-      db_query("CREATE TABLE {aggregator_item} (
-        iid serial,
-        fid int NOT NULL default '0',
-        title varchar(255) NOT NULL default '',
-        link varchar(255) NOT NULL default '',
-        author varchar(255) NOT NULL default '',
-        description text NOT NULL,
-        timestamp int default NULL,
-        guid varchar(255),
-        PRIMARY KEY (iid)
-      )");
-      db_query("CREATE INDEX {aggregator_item}_fid_idx ON {aggregator_item} (fid)");
-
-      break;
-  }
+  // Create tables.
+  drupal_load('module', 'aggregator');
+  $schemas = module_invoke('aggregator', 'schema');
+  db_create_schemas($schemas);
 }
 
 /**
Index: modules/aggregator/aggregator.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.module,v
retrieving revision 1.338
diff -u -F^f -r1.338 aggregator.module
--- modules/aggregator/aggregator.module	30 Apr 2007 17:03:22 -0000	1.338
+++ modules/aggregator/aggregator.module	3 May 2007 23:23:29 -0000
@@ -1430,3 +1430,12 @@ function aggregator_filter_xss($value) {
 function _aggregator_items($count) {
   return format_plural($count, '1 item', '@count items');
 }
+
+
+/**
+ * Implentation of hook_schema()
+ */
+function aggregator_schema() {
+  require_once(drupal_get_path('module', 'aggregator') .'/aggregator.schema');
+  return _aggregator_schema();
+}
Index: modules/aggregator/aggregator.schema
===================================================================
RCS file: modules/aggregator/aggregator.schema
diff -N modules/aggregator/aggregator.schema
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/aggregator/aggregator.schema	3 May 2007 23:23:29 -0000
@@ -0,0 +1,70 @@
+<?php
+// $Id: $
+
+function _aggregator_schema() {
+  $schema['aggregator_category'] = array(
+    'fields' => array(
+      'cid'         => array('type' => 'serial', 'not null' => TRUE),
+      'title'       => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'description' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'),
+      'block'       => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny')
+    ),
+    'primary key' => array('cid'),
+    'unique keys' => array('title' => array('title')),
+  );
+
+  $schema['aggregator_category_feed'] = array(
+    'fields' => array(
+      'fid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'cid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)
+    ),
+    'primary key' => array('fid', 'cid'),
+  );
+
+  $schema['aggregator_category_item'] = array(
+    'fields' => array(
+      'iid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'cid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)
+    ),
+    'primary key' => array('iid', 'cid'),
+  );
+
+  $schema['aggregator_feed'] = array(
+    'fields' => array(
+      'fid'         => array('type' => 'serial', 'not null' => TRUE),
+      'title'       => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'url'         => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'refresh'     => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'checked'     => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'link'        => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'description' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'),
+      'image'       => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'),
+      'etag'        => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'modified'    => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'block'       => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny')
+    ),
+    'unique keys' => array(
+      'link'  => array('url'),
+      'title' => array('title')
+    ),
+    'primary key' => array('fid'),
+  );
+
+  $schema['aggregator_item'] = array(
+    'fields' => array(
+      'iid'         => array('type' => 'serial', 'not null' => TRUE),
+      'fid'         => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'title'       => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'link'        => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'author'      => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'description' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'),
+      'timestamp'   => array('type' => 'int', 'not null' => FALSE),
+      'guid'        => array('type' => 'varchar', 'length' => 255, 'not null' => FALSE)
+    ),
+    'indexes' => array('fid' => array('fid')),
+    'primary key' => array('iid'),
+  );
+
+  return $schema;
+}
+
Index: modules/block/block.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.module,v
retrieving revision 1.258
diff -u -F^f -r1.258 block.module
--- modules/block/block.module	30 Apr 2007 17:03:23 -0000	1.258
+++ modules/block/block.module	3 May 2007 23:23:29 -0000
@@ -750,3 +750,12 @@ function block_list($region) {
   }
   return $blocks[$region];
 }
+
+
+/**
+ * Implentation of hook_schema()
+ */
+function block_schema() {
+  require_once(drupal_get_path('module', 'block') .'/block.schema');
+  return _block_schema();
+}
Index: modules/block/block.schema
===================================================================
RCS file: modules/block/block.schema
diff -N modules/block/block.schema
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/block/block.schema	3 May 2007 23:23:29 -0000
@@ -0,0 +1,47 @@
+<?php
+// $Id: $
+
+function _block_schema() {
+  $schema['blocks'] = array(
+    'fields' => array(
+      'module'     => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''),
+      'delta'      => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => 0),
+      'theme'      => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'status'     => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'weight'     => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'region'     => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => 'left'),
+      'custom'     => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'throttle'   => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'visibility' => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'pages'      => array('type' => 'text', 'not null' => TRUE),
+      'title'      => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => '')
+    ),
+  );
+
+  $schema['blocks_roles'] = array(
+    'fields' => array(
+      'module' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE),
+      'delta'  => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE),
+      'rid'    => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE)
+    ),
+    'primary key' => array(
+      'module',
+      'delta',
+      'rid'
+    ),
+  );
+
+  $schema['boxes'] = array(
+    'fields' => array(
+      'bid'    => array('type' => 'int', 'not null' => TRUE),
+      'body'   => array('type' => 'text', 'not null' => FALSE, 'size' => 'big'),
+      'info'   => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
+      'format' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)
+    ),
+    'unique keys' => array('info' => array('info')),
+    'primary key' => array('bid'),
+  );
+
+  return $schema;
+}
+
Index: modules/book/book.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.install,v
retrieving revision 1.6
diff -u -F^f -r1.6 book.install
--- modules/book/book.install	1 Sep 2006 07:40:08 -0000	1.6
+++ modules/book/book.install	3 May 2007 23:23:29 -0000
@@ -5,31 +5,10 @@
  * Implementation of hook_install().
  */
 function book_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE {book} (
-        vid int unsigned NOT NULL default '0',
-        nid int unsigned NOT NULL default '0',
-        parent int NOT NULL default '0',
-        weight tinyint NOT NULL default '0',
-        PRIMARY KEY (vid),
-        KEY nid (nid),
-        KEY parent (parent)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-      break;
-    case 'pgsql':
-      db_query("CREATE TABLE {book} (
-        vid int_unsigned NOT NULL default '0',
-        nid int_unsigned NOT NULL default '0',
-        parent int NOT NULL default '0',
-        weight smallint NOT NULL default '0',
-        PRIMARY KEY (vid)
-      )");
-      db_query("CREATE INDEX {book}_nid_idx ON {book} (nid)");
-      db_query("CREATE INDEX {book}_parent_idx ON {book} (parent)");
-      break;
-  }
+  // Create tables.
+  drupal_load('module', 'book');
+  $schemas = module_invoke('book', 'schema');
+  db_create_schemas($schemas);
 }
 
 /**
Index: modules/book/book.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.module,v
retrieving revision 1.419
diff -u -F^f -r1.419 book.module
--- modules/book/book.module	30 Apr 2007 17:03:24 -0000	1.419
+++ modules/book/book.module	3 May 2007 23:23:30 -0000
@@ -1005,3 +1005,12 @@ function book_help($section) {
 }
 
 
+
+
+/**
+ * Implentation of hook_schema()
+ */
+function book_schema() {
+  require_once(drupal_get_path('module', 'book') .'/book.schema');
+  return _book_schema();
+}
Index: modules/book/book.schema
===================================================================
RCS file: modules/book/book.schema
diff -N modules/book/book.schema
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/book/book.schema	3 May 2007 23:23:30 -0000
@@ -0,0 +1,21 @@
+<?php
+// $Id: $
+
+function _book_schema() {
+  $schema['book'] = array(
+    'fields' => array(
+      'vid'    => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'nid'    => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'parent' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'weight' => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny')
+    ),
+    'indexes' => array(
+      'nid'    => array('nid'),
+      'parent' => array('parent')
+    ),
+    'primary key' => array('vid'),
+  );
+
+  return $schema;
+}
+
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.541
diff -u -F^f -r1.541 comment.module
--- modules/comment/comment.module	30 Apr 2007 17:03:24 -0000	1.541
+++ modules/comment/comment.module	3 May 2007 23:23:31 -0000
@@ -2065,3 +2065,12 @@ function vancode2int($c = '00') {
   return base_convert(substr($c, 1), 36, 10);
 }
 
+
+
+/**
+ * Implentation of hook_schema()
+ */
+function comment_schema() {
+  require_once(drupal_get_path('module', 'comment') .'/comment.schema');
+  return _comment_schema();
+}
Index: modules/comment/comment.schema
===================================================================
RCS file: modules/comment/comment.schema
diff -N modules/comment/comment.schema
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/comment/comment.schema	3 May 2007 23:23:31 -0000
@@ -0,0 +1,45 @@
+<?php
+// $Id: $
+
+function _comment_schema() {
+  $schema['comments'] = array(
+    'fields' => array(
+      'cid'       => array('type' => 'serial', 'not null' => TRUE),
+      'pid'       => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'nid'       => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'uid'       => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'subject'   => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''),
+      'comment'   => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'),
+      'hostname'  => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
+      'timestamp' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'score'     => array('type' => 'int', 'disp_width' => 9, 'not null' => TRUE, 'default' => 0, 'size' => 'medium'),
+      'status'    => array('type' => 'int', 'disp_width' => 3, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'format'    => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'thread'    => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE),
+      'users'     => array('type' => 'text', 'not null' => FALSE, 'size' => 'big'),
+      'name'      => array('type' => 'varchar', 'length' => 60, 'not null' => FALSE),
+      'mail'      => array('type' => 'varchar', 'length' => 64, 'not null' => FALSE),
+      'homepage'  => array('type' => 'varchar', 'length' => 255, 'not null' => FALSE)
+    ),
+    'indexes' => array(
+      'lid'    => array('nid'),
+      'status' => array('status')
+    ),
+    'primary key' => array('cid'),
+  );
+
+  $schema['node_comment_statistics'] = array(
+    'fields' => array(
+      'nid'                    => array('type' => 'serial', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE),
+      'last_comment_timestamp' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'last_comment_name'      => array('type' => 'varchar', 'length' => 60, 'not null' => FALSE),
+      'last_comment_uid'       => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'comment_count'          => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
+    ),
+    'indexes' => array('node_comment_timestamp' => array('last_comment_timestamp')),
+    'primary key' => array('nid'),
+  );
+
+  return $schema;
+}
+
Index: modules/contact/contact.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/contact/contact.install,v
retrieving revision 1.6
diff -u -F^f -r1.6 contact.install
--- modules/contact/contact.install	2 Jan 2007 05:30:29 -0000	1.6
+++ modules/contact/contact.install	3 May 2007 23:23:31 -0000
@@ -5,33 +5,10 @@
  * Implementation of hook_install().
  */
 function contact_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE {contact} (
-        cid int unsigned NOT NULL auto_increment,
-        category varchar(255) NOT NULL default '',
-        recipients longtext NOT NULL,
-        reply longtext NOT NULL,
-        weight tinyint NOT NULL default '0',
-        selected tinyint NOT NULL default '0',
-        PRIMARY KEY (cid),
-        UNIQUE KEY category (category)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-      break;
-    case 'pgsql':
-      db_query("CREATE TABLE {contact} (
-        cid serial CHECK (cid >= 0),
-        category varchar(255) NOT NULL default '',
-        recipients text NOT NULL default '',
-        reply text NOT NULL default '',
-        weight smallint NOT NULL default '0',
-        selected smallint NOT NULL default '0',
-        PRIMARY KEY (cid),
-        UNIQUE (category)
-      )");
-      break;
-  }
+  // Create tables.
+  drupal_load('module', 'contact');
+  $schemas = module_invoke('contact', 'schema');
+  db_create_schemas($schemas);
 }
 
 /**
Index: modules/contact/contact.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/contact/contact.module,v
retrieving revision 1.83
diff -u -F^f -r1.83 contact.module
--- modules/contact/contact.module	30 Apr 2007 17:03:24 -0000	1.83
+++ modules/contact/contact.module	3 May 2007 23:23:31 -0000
@@ -553,3 +553,12 @@ function contact_mail_page_submit($form_
   return '';
 }
 
+
+
+/**
+ * Implentation of hook_schema()
+ */
+function contact_schema() {
+  require_once(drupal_get_path('module', 'contact') .'/contact.schema');
+  return _contact_schema();
+}
Index: modules/contact/contact.schema
===================================================================
RCS file: modules/contact/contact.schema
diff -N modules/contact/contact.schema
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/contact/contact.schema	3 May 2007 23:23:31 -0000
@@ -0,0 +1,20 @@
+<?php
+// $Id: $
+
+function _contact_schema() {
+  $schema['contact'] = array(
+    'fields' => array(
+      'cid'        => array('type' => 'serial', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE),
+      'category'   => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'recipients' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'),
+      'reply'      => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'),
+      'weight'     => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'selected'   => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny')
+    ),
+    'unique keys' => array('category' => array('category')),
+    'primary key' => array('cid'),
+  );
+
+  return $schema;
+}
+
Index: modules/dblog/dblog.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/dblog/dblog.install,v
retrieving revision 1.2
diff -u -F^f -r1.2 dblog.install
--- modules/dblog/dblog.install	24 Apr 2007 13:53:11 -0000	1.2
+++ modules/dblog/dblog.install	3 May 2007 23:23:31 -0000
@@ -5,46 +5,10 @@
  * Implementation of hook_install().
  */
 function dblog_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE {watchdog} (
-        wid int NOT NULL auto_increment,
-        uid int NOT NULL default '0',
-        type varchar(16) NOT NULL default '',
-        message longtext NOT NULL,
-        variables longtext NOT NULL,
-        severity tinyint unsigned NOT NULL default '0',
-        link varchar(255) NOT NULL default '',
-        location text NOT NULL,
-        referer varchar(128) NOT NULL default '',
-        hostname varchar(128) NOT NULL default '',
-        timestamp int NOT NULL default '0',
-        PRIMARY KEY (wid),
-        KEY (type)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-      break;
-
-    case 'pgsql':
-      db_query("CREATE TABLE {watchdog} (
-        wid serial,
-        uid int NOT NULL default '0',
-        type varchar(16) NOT NULL default '',
-        message text NOT NULL,
-        variables text NOT NULL,
-        severity smallint_unsigned NOT NULL default '0',
-        link varchar(255) NOT NULL default '',
-        location text NOT NULL default '',
-        referer varchar(128) NOT NULL default '',
-        hostname varchar(128) NOT NULL default '',
-        timestamp int NOT NULL default '0',
-        PRIMARY KEY (wid)
-      )");
-      db_query("CREATE INDEX {watchdog}_type_idx ON {watchdog} (type)");
-
-
-      break;
-  }
+  // Create tables.
+  drupal_load('module', 'dblog');
+  $schemas = module_invoke('dblog', 'schema');
+  db_create_schemas($schemas);
 }
 
 /**
Index: modules/dblog/dblog.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/dblog/dblog.module,v
retrieving revision 1.5
diff -u -F^f -r1.5 dblog.module
--- modules/dblog/dblog.module	30 Apr 2007 17:03:24 -0000	1.5
+++ modules/dblog/dblog.module	3 May 2007 23:23:31 -0000
@@ -452,3 +452,12 @@ function dblog_build_filter_query() {
     'args' => $args,
   );
 }
+
+
+/**
+ * Implentation of hook_schema()
+ */
+function dblog_schema() {
+  require_once(drupal_get_path('module', 'dblog') .'/dblog.schema');
+  return _dblog_schema();
+}
Index: modules/dblog/dblog.schema
===================================================================
RCS file: modules/dblog/dblog.schema
diff -N modules/dblog/dblog.schema
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/dblog/dblog.schema	3 May 2007 23:23:31 -0000
@@ -0,0 +1,25 @@
+<?php
+// $Id: $
+
+function _dblog_schema() {
+  $schema['watchdog'] = array(
+    'fields' => array(
+      'wid'       => array('type' => 'serial', 'not null' => TRUE),
+      'uid'       => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'type'      => array('type' => 'varchar', 'length' => 16, 'not null' => TRUE, 'default' => ''),
+      'message'   => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'),
+      'variables' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'),
+      'severity'  => array('type' => 'int', 'disp_width' => 3, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'link'      => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'location'  => array('type' => 'text', 'not null' => TRUE),
+      'referer'   => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
+      'hostname'  => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
+      'timestamp' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)
+    ),
+    'primary key' => array('wid'),
+    'indexes' => array('type' => array('type')),
+  );
+
+  return $schema;
+}
+
Index: modules/drupal/drupal.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/drupal/drupal.install,v
retrieving revision 1.5
diff -u -F^f -r1.5 drupal.install
--- modules/drupal/drupal.install	1 Sep 2006 07:40:08 -0000	1.5
+++ modules/drupal/drupal.install	3 May 2007 23:23:31 -0000
@@ -5,55 +5,10 @@
  * Implementation of hook_install().
  */
 function drupal_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE {client} (
-        cid int unsigned NOT NULL auto_increment,
-        link varchar(255) NOT NULL default '',
-        name varchar(128) NOT NULL default '',
-        mail varchar(128) NOT NULL default '',
-        slogan longtext NOT NULL,
-        mission longtext NOT NULL,
-        users int NOT NULL default '0',
-        nodes int NOT NULL default '0',
-        version varchar(35) NOT NULL default'',
-        created int NOT NULL default '0',
-        changed int NOT NULL default '0',
-        PRIMARY KEY (cid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {client_system} (
-        cid int NOT NULL default '0',
-        name varchar(255) NOT NULL default '',
-        type varchar(255) NOT NULL default '',
-        PRIMARY KEY (cid,name)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-      break;
-    case 'pgsql':
-      db_query("CREATE TABLE {client} (
-        cid serial CHECK (cid >= 0),
-        link varchar(255) NOT NULL default '',
-        name varchar(128) NOT NULL default '',
-        mail varchar(128) NOT NULL default '',
-        slogan text NOT NULL,
-        mission text NOT NULL,
-        users int NOT NULL default '0',
-        nodes int NOT NULL default '0',
-        version varchar(35) NOT NULL default'',
-        created int NOT NULL default '0',
-        changed int NOT NULL default '0',
-        PRIMARY KEY (cid)
-      )");
-
-      db_query("CREATE TABLE {client_system} (
-        cid int NOT NULL default '0',
-        name varchar(255) NOT NULL default '',
-        type varchar(255) NOT NULL default '',
-        PRIMARY KEY (cid,name)
-      )");
-      break;
-  }
+  // Create tables.
+  drupal_load('module', 'drupal');
+  $schemas = module_invoke('drupal', 'schema');
+  db_create_schemas($schemas);
 }
 
 /**
Index: modules/drupal/drupal.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/drupal/drupal.module,v
retrieving revision 1.144
diff -u -F^f -r1.144 drupal.module
--- modules/drupal/drupal.module	30 Apr 2007 17:03:24 -0000	1.144
+++ modules/drupal/drupal.module	3 May 2007 23:23:31 -0000
@@ -395,3 +395,12 @@ function drupal_login($username, $passwo
     }
   }
 }
+
+
+/**
+ * Implentation of hook_schema()
+ */
+function drupal_schema() {
+  require_once(drupal_get_path('module', 'drupal') .'/drupal.schema');
+  return _drupal_schema();
+}
Index: modules/drupal/drupal.schema
===================================================================
RCS file: modules/drupal/drupal.schema
diff -N modules/drupal/drupal.schema
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/drupal/drupal.schema	3 May 2007 23:23:31 -0000
@@ -0,0 +1,33 @@
+<?php
+// $Id: $
+
+function _drupal_schema() {
+  $schema['client'] = array(
+    'fields' => array(
+      'cid'     => array('type' => 'serial', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE),
+      'link'    => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'name'    => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
+      'mail'    => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
+      'slogan'  => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'),
+      'mission' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'),
+      'users'   => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'nodes'   => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'version' => array('type' => 'varchar', 'length' => 35, 'not null' => TRUE, 'default' => ''),
+      'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'changed' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)
+    ),
+    'primary key' => array('cid'),
+  );
+
+  $schema['client_system'] = array(
+    'fields' => array(
+      'cid'  => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'type' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')
+    ),
+    'primary key' => array('cid', 'name'),
+  );
+
+  return $schema;
+}
+
Index: modules/filter/filter.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v
retrieving revision 1.172
diff -u -F^f -r1.172 filter.module
--- modules/filter/filter.module	30 Apr 2007 17:03:24 -0000	1.172
+++ modules/filter/filter.module	3 May 2007 23:23:32 -0000
@@ -1474,3 +1474,12 @@ function filter_xss_bad_protocol($string
  * @} End of "Standard filters".
  */
 
+
+
+/**
+ * Implentation of hook_schema()
+ */
+function filter_schema() {
+  require_once(drupal_get_path('module', 'filter') .'/filter.schema');
+  return _filter_schema();
+}
Index: modules/filter/filter.schema
===================================================================
RCS file: modules/filter/filter.schema
diff -N modules/filter/filter.schema
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/filter/filter.schema	3 May 2007 23:23:32 -0000
@@ -0,0 +1,28 @@
+<?php
+// $Id: $
+
+function _filter_schema() {
+  $schema['filters'] = array(
+    'fields' => array(
+      'format' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'module' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''),
+      'delta'  => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'weight' => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny')
+    ),
+    'indexes' => array('weight' => array('weight')),
+  );
+
+  $schema['filter_formats'] = array(
+    'fields' => array(
+      'format' => array('type' => 'serial', 'not null' => TRUE),
+      'name'   => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'roles'  => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'cache'  => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny')
+    ),
+    'unique keys' => array('name' => array('name')),
+    'primary key' => array('format'),
+  );
+
+  return $schema;
+}
+
Index: modules/forum/forum.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.install,v
retrieving revision 1.6
diff -u -F^f -r1.6 forum.install
--- modules/forum/forum.install	1 Sep 2006 07:40:08 -0000	1.6
+++ modules/forum/forum.install	3 May 2007 23:23:32 -0000
@@ -5,29 +5,10 @@
  * Implementation of hook_install().
  */
 function forum_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE {forum} (
-        nid int unsigned NOT NULL default '0',
-        vid int unsigned NOT NULL default '0',
-        tid int unsigned NOT NULL default '0',
-        PRIMARY KEY (vid),
-        KEY nid (nid),
-        KEY tid (tid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-      break;
-    case 'pgsql':
-      db_query("CREATE TABLE {forum} (
-        nid int_unsigned NOT NULL default '0',
-        vid int_unsigned NOT NULL default '0',
-        tid int_unsigned NOT NULL default '0',
-        PRIMARY KEY (vid)
-      )");
-      db_query("CREATE INDEX {forum}_nid_idx ON {forum} (nid)");
-      db_query("CREATE INDEX {forum}_tid_idx ON {forum} (tid)");
-      break;
-  }
+  // Create tables.
+  drupal_load('module', 'forum');
+  $schemas = module_invoke('forum', 'schema');
+  db_create_schemas($schemas);
 }
 
 /**
Index: modules/forum/forum.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v
retrieving revision 1.395
diff -u -F^f -r1.395 forum.module
--- modules/forum/forum.module	30 Apr 2007 17:03:25 -0000	1.395
+++ modules/forum/forum.module	3 May 2007 23:23:33 -0000
@@ -1185,3 +1185,12 @@ function _forum_get_topic_order_sql($sor
 }
 
 
+
+
+/**
+ * Implentation of hook_schema()
+ */
+function forum_schema() {
+  require_once(drupal_get_path('module', 'forum') .'/forum.schema');
+  return _forum_schema();
+}
Index: modules/forum/forum.schema
===================================================================
RCS file: modules/forum/forum.schema
diff -N modules/forum/forum.schema
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/forum/forum.schema	3 May 2007 23:23:33 -0000
@@ -0,0 +1,20 @@
+<?php
+// $Id: $
+
+function _forum_schema() {
+  $schema['forum'] = array(
+    'fields' => array(
+      'nid' => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'vid' => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'tid' => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
+    ),
+    'indexes' => array(
+      'nid' => array('nid'),
+      'tid' => array('tid')
+    ),
+    'primary key' => array('vid'),
+  );
+
+  return $schema;
+}
+
Index: modules/locale/locale.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/locale/locale.install,v
retrieving revision 1.9
diff -u -F^f -r1.9 locale.install
--- modules/locale/locale.install	3 May 2007 09:51:08 -0000	1.9
+++ modules/locale/locale.install	3 May 2007 23:23:33 -0000
@@ -8,82 +8,12 @@ function locale_install() {
   // locales_source.source and locales_target.target are not used as binary
   // fields; non-MySQL database servers need to ensure the field type is text
   // and that LIKE produces a case-sensitive comparison.
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE {languages} (
-        language varchar(12) NOT NULL default '',
-        name varchar(64) NOT NULL default '',
-        native varchar(64) NOT NULL default '',
-        direction int NOT NULL default '0',
-        enabled int NOT NULL default '0',
-        plurals int NOT NULL default '0',
-        formula varchar(128) NOT NULL default '',
-        domain varchar(128) NOT NULL default '',
-        prefix varchar(128) NOT NULL default '',
-        weight int NOT NULL default '0',
-        PRIMARY KEY (language)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {locales_source} (
-        lid int NOT NULL auto_increment,
-        location varchar(255) NOT NULL default '',
-        textgroup varchar(255) NOT NULL default '',
-        source blob NOT NULL,
-        PRIMARY KEY (lid),
-        KEY source (source(30))
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {locales_target} (
-        lid int NOT NULL default '0',
-        translation blob NOT NULL,
-        language varchar(12) NOT NULL default '',
-        plid int NOT NULL default '0',
-        plural int NOT NULL default '0',
-        KEY lid (lid),
-        KEY lang (language),
-        KEY plid (plid),
-        KEY plural (plural)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-      break;
-
-    case 'pgsql':
-      db_query("CREATE TABLE {languages} (
-        language varchar(12) NOT NULL default '',
-        name varchar(64) NOT NULL default '',
-        native varchar(64) NOT NULL default '',
-        direction int NOT NULL default '0',
-        enabled int NOT NULL default '0',
-        plurals int NOT NULL default '0',
-        formula varchar(128) NOT NULL default '',
-        domain varchar(128) NOT NULL default '',
-        prefix varchar(128) NOT NULL default '',
-        weight int NOT NULL default '0',
-        PRIMARY KEY (language)
-      )");
-
-      db_query("CREATE TABLE {locales_source} (
-        lid serial,
-        location varchar(255) NOT NULL default '',
-        textgroup varchar(255) NOT NULL default '',
-        source text NOT NULL,
-        PRIMARY KEY (lid)
-      )");
-
-      db_query("CREATE TABLE {locales_target} (
-        lid int NOT NULL default '0',
-        translation text NOT NULL,
-        language varchar(12) NOT NULL default '',
-        plid int NOT NULL default '0',
-        plural int NOT NULL default '0'
-      )");
-      db_query("CREATE INDEX {locales_target}_lid_idx ON {locales_target} (lid)");
-      db_query("CREATE INDEX {locales_target}_language_idx ON {locales_target} (language)");
-      db_query("CREATE INDEX {locales_target}_plid_idx ON {locales_target} (plid)");
-      db_query("CREATE INDEX {locales_target}_plural_idx ON {locales_target} (plural)");
-      db_query("CREATE INDEX {locales_source}_source_idx ON {locales_source} (source)");
-      break;
-  }
+  
+  // Create tables.
+  drupal_load('module', 'locale');
+  $schemas = module_invoke('locale', 'schema');
+  db_create_schemas($schemas);
+  
   db_query("INSERT INTO {languages} (language, name, native, direction, enabled, weight) VALUES ('en', 'English', 'English', '0', '1', '0')");
 }
 
Index: modules/locale/locale.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/locale/locale.module,v
retrieving revision 1.171
diff -u -F^f -r1.171 locale.module
--- modules/locale/locale.module	3 May 2007 09:51:08 -0000	1.171
+++ modules/locale/locale.module	3 May 2007 23:23:33 -0000
@@ -422,3 +422,11 @@ function locale_language_list($field = '
   }
   return $list;
 }
+
+/**
+ * Implentation of hook_schema()
+ */
+function locale_schema() {
+  require_once(drupal_get_path('module', 'locale') .'/locale.schema');
+  return _locale_schema();
+}
Index: modules/locale/locale.schema
===================================================================
RCS file: modules/locale/locale.schema
diff -N modules/locale/locale.schema
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/locale/locale.schema	3 May 2007 23:23:33 -0000
@@ -0,0 +1,49 @@
+<?php
+// $Id: $
+
+function _locale_schema() {
+  $schema['languages'] = array(
+    'fields' => array(
+      'language'  => array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''),
+      'name'      => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''),
+      'native'    => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''),
+      'direction' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'enabled'   => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'plurals'   => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'formula'   => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
+      'domain'    => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
+      'prefix'    => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
+      'weight'    => array('type' => 'int', 'not null' => TRUE, 'default' => 0)
+    ),
+    'primary key' => array('language'),
+  );
+  
+  $schema['locales_source'] = array(
+    'fields' => array(
+      'lid'       => array('type' => 'serial', 'not null' => TRUE),
+      'location'  => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'textgroup' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'source'    => array('type' => 'blob', 'not null' => TRUE),
+    ),
+    'primary key' => array('lid'),
+  );
+  
+  $schema['locales_target'] = array(
+    'fields' => array(
+      'lid'         => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'translation' => array('type' => 'blob', 'not null' => TRUE),
+      'language'    => array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''),
+      'plid'        => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'plural'      => array('type' => 'int', 'not null' => TRUE, 'default' => 0)
+    ),
+    'indexes' => array(
+      'lang'   => array('language'),
+      'lid'    => array('lid'),
+      'plid'   => array('plid'),
+      'plural' => array('plural')
+    ),
+  );
+
+  return $schema;
+}
+
Index: modules/menu/menu.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/menu/menu.install,v
retrieving revision 1.2
diff -u -F^f -r1.2 menu.install
--- modules/menu/menu.install	15 Apr 2007 14:38:16 -0000	1.2
+++ modules/menu/menu.install	3 May 2007 23:23:33 -0000
@@ -5,35 +5,10 @@
  * Implementation of hook_install().
  */
 function menu_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE {menu_custom} (
-        path varchar(255) NOT NULL default '' ,
-        disabled int NOT NULL default 0,
-        title varchar(255) NOT NULL default '',
-        description varchar(255) NOT NULL default '',
-        weight int NOT NULL default 0 ,
-        type int NOT NULL default 0 ,
-        admin int NOT NULL default 0,
-        parent varchar(255) NOT NULL default '',
-        PRIMARY KEY (path)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-      break;
-    case 'pgsql':
-      db_query("CREATE TABLE {menu_custom} (
-        path varchar(255) NOT NULL default '' ,
-        disabled int NOT NULL default 0,
-        title varchar(255) NOT NULL default '',
-        description varchar(255) NOT NULL default '',
-        weight int NOT NULL default 0 ,
-        type int NOT NULL default 0 ,
-        admin int NOT NULL default 0,
-        parent varchar(255) NOT NULL default '',
-        PRIMARY KEY (path)
-      )");
-      break;
-  }
+  // Create tables.
+  drupal_load('module', 'menu');
+  $schemas = module_invoke('menu', 'schema');
+  db_create_schemas($schemas);
 }
 
 /**
Index: modules/menu/menu.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/menu/menu.module,v
retrieving revision 1.109
diff -u -F^f -r1.109 menu.module
--- modules/menu/menu.module	30 Apr 2007 17:03:25 -0000	1.109
+++ modules/menu/menu.module	3 May 2007 23:23:33 -0000
@@ -756,3 +756,12 @@ function _menu_overview_tree() {
   }
   return $output;
 }
+
+
+/**
+ * Implentation of hook_schema()
+ */
+function menu_schema() {
+  require_once(drupal_get_path('module', 'menu') .'/menu.schema');
+  return _menu_schema();
+}
Index: modules/menu/menu.schema
===================================================================
RCS file: modules/menu/menu.schema
diff -N modules/menu/menu.schema
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/menu/menu.schema	3 May 2007 23:23:33 -0000
@@ -0,0 +1,21 @@
+<?php
+// $Id: $
+
+function _menu_schema() {
+  $schema['menu_custom'] = array(
+    'fields' => array(
+      'path'        => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'disabled'    => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'title'       => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'description' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'weight'      => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'type'        => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'admin'       => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'parent'      => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')
+    ),
+    'primary key' => array('path'),
+  );
+
+  return $schema;
+}
+
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.806
diff -u -F^f -r1.806 node.module
--- modules/node/node.module	30 Apr 2007 17:03:26 -0000	1.806
+++ modules/node/node.module	3 May 2007 23:23:35 -0000
@@ -3074,3 +3074,12 @@ function node_forms() {
   }
   return $forms;
 }
+
+
+/**
+ * Implentation of hook_schema()
+ */
+function node_schema() {
+  require_once(drupal_get_path('module', 'node') .'/node.schema');
+  return _node_schema();
+}
Index: modules/node/node.schema
===================================================================
RCS file: modules/node/node.schema
diff -N modules/node/node.schema
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/node/node.schema	3 May 2007 23:23:35 -0000
@@ -0,0 +1,104 @@
+<?php
+// $Id: $
+
+function _node_schema() {
+  $schema['node'] = array(
+    'fields' => array(
+      'nid'      => array('type' => 'serial', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE),
+      'vid'      => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'type'     => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''),
+      'language' => array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''),
+      'title'    => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
+      'uid'      => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'status'   => array('type' => 'int', 'not null' => TRUE, 'default' => 1),
+      'created'  => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'changed'  => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'comment'  => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'promote'  => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'moderate' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'sticky'   => array('type' => 'int', 'not null' => TRUE, 'default' => 0)
+    ),
+    'indexes' => array(
+      'nid'                 => array('nid'),
+      'node_changed'        => array('changed'),
+      'node_created'        => array('created'),
+      'node_moderate'       => array('moderate'),
+      'node_promote_status' => array('promote', 'status'),
+      'node_status_type'    => array('status', 'type', 'nid'),
+      'node_title_type'     => array('title', 'type'),
+      'node_type'           => array('type'),
+      'status'              => array('status'),
+      'uid'                 => array('uid')
+    ),
+    'primary key' => array('nid', 'vid'),
+    'unique keys' => array('vid' => array('vid')),
+  );
+
+  $schema['node_access'] = array(
+    'fields' => array(
+      'nid'          => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'gid'          => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'realm'        => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'grant_view'   => array('type' => 'int', 'disp_width' => 3, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'grant_update' => array('type' => 'int', 'disp_width' => 3, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'grant_delete' => array('type' => 'int', 'disp_width' => 3, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny')
+    ),
+    'primary key' => array(
+      'nid',
+      'gid',
+      'realm'
+    ),
+  );
+
+  $schema['node_counter'] = array(
+    'fields' => array(
+      'nid'        => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'totalcount' => array('type' => 'int', 'disp_width' => 20, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'big'),
+      'daycount'   => array('type' => 'int', 'disp_width' => 8, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'medium'),
+      'timestamp'  => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
+    ),
+    'primary key' => array('nid'),
+  );
+
+  $schema['node_revisions'] = array(
+    'fields' => array(
+      'nid'       => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE),
+      'vid'       => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE),
+      'uid'       => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'title'     => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
+      'body'      => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'),
+      'teaser'    => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'),
+      'log'       => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'),
+      'timestamp' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'format'    => array('type' => 'int', 'not null' => TRUE, 'default' => 0)
+    ),
+    'indexes' => array(
+      'nid' => array('nid'),
+      'uid' => array('uid')
+    ),
+    'primary key' => array('vid'),
+  );
+
+  $schema['node_type'] = array(
+    'fields' => array(
+      'type'           => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE),
+      'name'           => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'module'         => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE),
+      'description'    => array('type' => 'text', 'not null' => TRUE, 'size' => 'medium'),
+      'help'           => array('type' => 'text', 'not null' => TRUE, 'size' => 'medium'),
+      'has_title'      => array('type' => 'int', 'disp_width' => 3, 'unsigned' => TRUE, 'not null' => TRUE, 'size' => 'tiny'),
+      'title_label'    => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'has_body'       => array('type' => 'int', 'disp_width' => 3, 'unsigned' => TRUE, 'not null' => TRUE, 'size' => 'tiny'),
+      'body_label'     => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'min_word_count' => array('type' => 'int', 'disp_width' => 5, 'unsigned' => TRUE, 'not null' => TRUE, 'size' => 'small'),
+      'custom'         => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'modified'       => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'locked'         => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'orig_type'      => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')
+    ),
+    'primary key' => array('type'),
+  );
+
+  return $schema;
+}
+
Index: modules/poll/poll.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.install,v
retrieving revision 1.7
diff -u -F^f -r1.7 poll.install
--- modules/poll/poll.install	1 Sep 2006 07:40:08 -0000	1.7
+++ modules/poll/poll.install	3 May 2007 23:23:35 -0000
@@ -5,66 +5,10 @@
  * Implementation of hook_install().
  */
 function poll_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE {poll} (
-        nid int unsigned NOT NULL default '0',
-        runtime int NOT NULL default '0',
-        active int unsigned NOT NULL default '0',
-        PRIMARY KEY (nid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {poll_votes} (
-        nid int unsigned NOT NULL,
-        uid int unsigned NOT NULL default 0,
-        chorder int NOT NULL default -1,
-        hostname varchar(128) NOT NULL default '',
-        INDEX (nid),
-        INDEX (uid),
-        INDEX (hostname)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {poll_choices} (
-        chid int unsigned NOT NULL auto_increment,
-        nid int unsigned NOT NULL default '0',
-        chtext varchar(128) NOT NULL default '',
-        chvotes int NOT NULL default '0',
-        chorder int NOT NULL default '0',
-        PRIMARY KEY (chid),
-        KEY nid (nid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-      break;
-
-    case 'pgsql':
-      db_query("CREATE TABLE {poll} (
-        nid int_unsigned NOT NULL default '0',
-        runtime int NOT NULL default '0',
-        active int_unsigned NOT NULL default '0',
-        PRIMARY KEY (nid)
-      )");
-
-      db_query("CREATE TABLE {poll_votes} (
-        nid int_unsigned NOT NULL,
-        uid int_unsigned NOT NULL default 0,
-        chorder int NOT NULL default -1,
-        hostname varchar(128) NOT NULL default ''
-      )");
-      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} (
-        chid serial CHECK (chid >= 0),
-        nid int_unsigned NOT NULL default '0',
-        chtext varchar(128) NOT NULL default '',
-        chvotes int NOT NULL default '0',
-        chorder int NOT NULL default '0',
-        PRIMARY KEY (chid)
-      )");
-      db_query("CREATE INDEX {poll_choices}_nid_idx ON {poll_choices} (nid)");
-      break;
-  }
+  // Create tables.
+  drupal_load('module', 'poll');
+  $schemas = module_invoke('poll', 'schema');
+  db_create_schemas($schemas);
 }
 
 /**
Index: modules/poll/poll.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.module,v
retrieving revision 1.227
diff -u -F^f -r1.227 poll.module
--- modules/poll/poll.module	30 Apr 2007 17:03:27 -0000	1.227
+++ modules/poll/poll.module	3 May 2007 23:23:35 -0000
@@ -660,3 +660,12 @@ function poll_user($op, &$edit, &$user) 
     db_query('UPDATE {poll_votes} SET uid = 0 WHERE uid = %d', $user->uid);
   }
 }
+
+
+/**
+ * Implentation of hook_schema()
+ */
+function poll_schema() {
+  require_once(drupal_get_path('module', 'poll') .'/poll.schema');
+  return _poll_schema();
+}
Index: modules/poll/poll.schema
===================================================================
RCS file: modules/poll/poll.schema
diff -N modules/poll/poll.schema
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/poll/poll.schema	3 May 2007 23:23:35 -0000
@@ -0,0 +1,42 @@
+<?php
+// $Id: $
+
+function _poll_schema() {
+  $schema['poll'] = array(
+    'fields' => array(
+      'nid'     => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'runtime' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'active'  => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
+    ),
+    'primary key' => array('nid'),
+  );
+
+  $schema['poll_choices'] = array(
+    'fields' => array(
+      'chid'    => array('type' => 'serial', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE),
+      'nid'     => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'chtext'  => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
+      'chvotes' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'chorder' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)
+    ),
+    'indexes' => array('nid' => array('nid')),
+    'primary key' => array('chid'),
+  );
+
+  $schema['poll_votes'] = array(
+    'fields' => array(
+      'nid'      => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE),
+      'uid'      => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'chorder'  => array('type' => 'int', 'not null' => TRUE, 'default' => -1),
+      'hostname' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '')
+    ),
+    'indexes' => array(
+      'hostname' => array('hostname'),
+      'nid'      => array('nid'),
+      'uid'      => array('uid')
+    ),
+  );
+
+  return $schema;
+}
+
Index: modules/profile/profile.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.install,v
retrieving revision 1.8
diff -u -F^f -r1.8 profile.install
--- modules/profile/profile.install	28 Nov 2006 14:37:44 -0000	1.8
+++ modules/profile/profile.install	3 May 2007 23:23:35 -0000
@@ -5,66 +5,10 @@
  * Implementation of hook_install().
  */
 function profile_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE {profile_fields} (
-        fid int NOT NULL auto_increment,
-        title varchar(255) default NULL,
-        name varchar(128) default NULL,
-        explanation TEXT,
-        category varchar(255) default NULL,
-        page varchar(255) default NULL,
-        type varchar(128) default NULL,
-        weight tinyint DEFAULT '0' NOT NULL,
-        required tinyint DEFAULT '0' NOT NULL,
-        register tinyint DEFAULT '0' NOT NULL,
-        visibility tinyint DEFAULT '0' NOT NULL,
-        autocomplete tinyint DEFAULT '0' NOT NULL,
-        options text,
-        KEY category (category),
-        UNIQUE KEY name (name),
-        PRIMARY KEY (fid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {profile_values} (
-        fid int unsigned default '0',
-        uid int unsigned default '0',
-        value text,
-        KEY uid (uid),
-        KEY fid (fid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-      break;
-
-    case 'pgsql':
-      db_query("CREATE TABLE {profile_fields} (
-        fid serial,
-        title varchar(255) default NULL,
-        name varchar(128) default NULL,
-        explanation TEXT default NULL,
-        category varchar(255) default NULL,
-        page varchar(255) default NULL,
-        type varchar(128) default NULL,
-        weight smallint DEFAULT '0' NOT NULL,
-        required smallint DEFAULT '0' NOT NULL,
-        register smallint DEFAULT '0' NOT NULL,
-        visibility smallint DEFAULT '0' NOT NULL,
-        autocomplete smallint DEFAULT '0' NOT NULL,
-        options text,
-        UNIQUE (name),
-        PRIMARY KEY (fid)
-      )");
-      db_query("CREATE INDEX {profile_fields}_category_idx ON {profile_fields} (category)");
-
-      db_query("CREATE TABLE {profile_values} (
-        fid int_unsigned default '0',
-        uid int_unsigned default '0',
-        value text
-      )");
-      db_query("CREATE INDEX {profile_values}_uid_idx ON {profile_values} (uid)");
-      db_query("CREATE INDEX {profile_values}_fid_idx ON {profile_values} (fid)");
-      break;
-  }
+  // Create tables.
+  drupal_load('module', 'profile');
+  $schemas = module_invoke('profile', 'schema');
+  db_create_schemas($schemas);
 }
 
 /**
Index: modules/profile/profile.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.module,v
retrieving revision 1.200
diff -u -F^f -r1.200 profile.module
--- modules/profile/profile.module	30 Apr 2007 17:03:27 -0000	1.200
+++ modules/profile/profile.module	3 May 2007 23:23:36 -0000
@@ -862,3 +862,12 @@ function profile_admin_settings_autocomp
   print drupal_to_js($matches);
   exit();
 }
+
+
+/**
+ * Implentation of hook_schema()
+ */
+function profile_schema() {
+  require_once(drupal_get_path('module', 'profile') .'/profile.schema');
+  return _profile_schema();
+}
Index: modules/profile/profile.schema
===================================================================
RCS file: modules/profile/profile.schema
diff -N modules/profile/profile.schema
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/profile/profile.schema	3 May 2007 23:23:36 -0000
@@ -0,0 +1,40 @@
+<?php
+// $Id: $
+
+function _profile_schema() {
+  $schema['profile_fields'] = array(
+    'fields' => array(
+      'fid'          => array('type' => 'serial', 'not null' => TRUE),
+      'title'        => array('type' => 'varchar', 'length' => 255, 'not null' => FALSE),
+      'name'         => array('type' => 'varchar', 'length' => 128, 'not null' => FALSE),
+      'explanation'  => array('type' => 'text', 'not null' => FALSE),
+      'category'     => array('type' => 'varchar', 'length' => 255, 'not null' => FALSE),
+      'page'         => array('type' => 'varchar', 'length' => 255, 'not null' => FALSE),
+      'type'         => array('type' => 'varchar', 'length' => 128, 'not null' => FALSE),
+      'weight'       => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'required'     => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'register'     => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'visibility'   => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'autocomplete' => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'options'      => array('type' => 'text', 'not null' => FALSE)
+    ),
+    'indexes' => array('category' => array('category')),
+    'unique keys' => array('name' => array('name')),
+    'primary key' => array('fid'),
+  );
+
+  $schema['profile_values'] = array(
+    'fields' => array(
+      'fid'   => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => FALSE, 'default' => 0),
+      'uid'   => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => FALSE, 'default' => 0),
+      'value' => array('type' => 'text', 'not null' => FALSE)
+    ),
+    'indexes' => array(
+      'fid' => array('fid'),
+      'uid' => array('uid')
+    ),
+  );
+
+  return $schema;
+}
+
Index: modules/search/search.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.install,v
retrieving revision 1.6
diff -u -F^f -r1.6 search.install
--- modules/search/search.install	1 Sep 2006 07:40:08 -0000	1.6
+++ modules/search/search.install	3 May 2007 23:23:36 -0000
@@ -5,61 +5,10 @@
  * Implementation of hook_install().
  */
 function search_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE {search_dataset} (
-        sid int unsigned NOT NULL default '0',
-        type varchar(16) default NULL,
-        data longtext NOT NULL,
-        KEY sid_type (sid, type)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {search_index} (
-        word varchar(50) NOT NULL default '',
-        sid int unsigned NOT NULL default '0',
-        type varchar(16) default NULL,
-        fromsid int unsigned NOT NULL default '0',
-        fromtype varchar(16) default NULL,
-        score float default NULL,
-        KEY sid_type (sid, type),
-        KEY from_sid_type (fromsid, fromtype),
-        KEY word (word)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {search_total} (
-        word varchar(50) NOT NULL default '',
-        count float default NULL,
-        PRIMARY KEY (word)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-      break;
-    case 'pgsql':
-      db_query("CREATE TABLE {search_dataset} (
-        sid int_unsigned NOT NULL default '0',
-        type varchar(16) default NULL,
-        data text NOT NULL
-      )");
-      db_query("CREATE INDEX {search_dataset}_sid_type_idx ON {search_dataset} (sid, type)");
-
-      db_query("CREATE TABLE {search_index} (
-        word varchar(50) NOT NULL default '',
-        sid int_unsigned NOT NULL default '0',
-        type varchar(16) default NULL,
-        fromsid int_unsigned NOT NULL default '0',
-        fromtype varchar(16) default NULL,
-        score float default NULL
-      )");
-      db_query("CREATE INDEX {search_index}_sid_type_idx ON {search_index} (sid, type)");
-      db_query("CREATE INDEX {search_index}_from_sid_type_idx ON {search_index} (fromsid, fromtype)");
-      db_query("CREATE INDEX {search_index}_word_idx ON {search_index} (word)");
-
-      db_query("CREATE TABLE {search_total} (
-        word varchar(50) NOT NULL default '',
-        count float default NULL,
-        PRIMARY KEY (word)
-      )");
-      break;
-  }
+  // Create tables.
+  drupal_load('module', 'search');
+  $schemas = module_invoke('search', 'schema');
+  db_create_schemas($schemas);
 }
 
 /**
Index: modules/search/search.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.module,v
retrieving revision 1.220
diff -u -F^f -r1.220 search.module
--- modules/search/search.module	30 Apr 2007 17:03:27 -0000	1.220
+++ modules/search/search.module	3 May 2007 23:23:36 -0000
@@ -1317,3 +1317,12 @@ function search_forms() {
   );
   return $forms;
 }
+
+
+/**
+ * Implentation of hook_schema()
+ */
+function search_schema() {
+  require_once(drupal_get_path('module', 'search') .'/search.schema');
+  return _search_schema();
+}
Index: modules/search/search.schema
===================================================================
RCS file: modules/search/search.schema
diff -N modules/search/search.schema
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/search/search.schema	3 May 2007 23:23:36 -0000
@@ -0,0 +1,40 @@
+<?php
+// $Id: $
+
+function _search_schema() {
+  $schema['search_dataset'] = array(
+    'fields' => array(
+      'sid'  => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'type' => array('type' => 'varchar', 'length' => 16, 'not null' => FALSE),
+      'data' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big')
+    ),
+    'indexes' => array('sid_type' => array('sid', 'type')),
+  );
+
+  $schema['search_index'] = array(
+    'fields' => array(
+      'word'     => array('type' => 'varchar', 'length' => 50, 'not null' => TRUE, 'default' => ''),
+      'sid'      => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'type'     => array('type' => 'varchar', 'length' => 16, 'not null' => FALSE),
+      'fromsid'  => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'fromtype' => array('type' => 'varchar', 'length' => 16, 'not null' => FALSE),
+      'score'    => array('type' => 'float', 'not null' => FALSE)
+    ),
+    'indexes' => array(
+      'from_sid_type' => array('fromsid', 'fromtype'),
+      'sid_type'      => array('sid', 'type'),
+      'word'          => array('word')
+    ),
+  );
+
+  $schema['search_total'] = array(
+    'fields' => array(
+      'word'  => array('type' => 'varchar', 'length' => 50, 'not null' => TRUE, 'default' => ''),
+      'count' => array('type' => 'float', 'not null' => FALSE)
+    ),
+    'primary key' => array('word'),
+  );
+
+  return $schema;
+}
+
Index: modules/statistics/statistics.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.install,v
retrieving revision 1.7
diff -u -F^f -r1.7 statistics.install
--- modules/statistics/statistics.install	7 Nov 2006 22:27:07 -0000	1.7
+++ modules/statistics/statistics.install	3 May 2007 23:23:36 -0000
@@ -5,39 +5,10 @@
  * Implementation of hook_install().
  */
 function statistics_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE {accesslog} (
-        aid int NOT NULL auto_increment,
-        sid varchar(64) NOT NULL default '',
-        title varchar(255) default NULL,
-        path varchar(255) default NULL,
-        url varchar(255) default NULL,
-        hostname varchar(128) default NULL,
-        uid int unsigned default '0',
-        timer int unsigned NOT NULL default '0',
-        timestamp int unsigned NOT NULL default '0',
-        KEY accesslog_timestamp (timestamp),
-        PRIMARY KEY (aid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-      break;
-    case 'pgsql':
-      db_query("CREATE TABLE {accesslog} (
-        aid serial,
-        sid varchar(64) NOT NULL default '',
-        title varchar(255) default NULL,
-        path varchar(255) default NULL,
-        url varchar(255) default NULL,
-        hostname varchar(128) default NULL,
-        uid int_unsigned default '0',
-        timer int_unsigned NOT NULL default '0',
-        timestamp int_unsigned NOT NULL default '0',
-        PRIMARY KEY (aid)
-      )");
-      db_query("CREATE INDEX {accesslog}_accesslog_timestamp_idx ON {accesslog} (timestamp)");
-      break;
-  }
+  // Create tables.
+  drupal_load('module', 'statistics');
+  $schemas = module_invoke('statistics', 'schema');
+  db_create_schemas($schemas);
 }
 
 /**
Index: modules/statistics/statistics.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.module,v
retrieving revision 1.258
diff -u -F^f -r1.258 statistics.module
--- modules/statistics/statistics.module	30 Apr 2007 17:03:27 -0000	1.258
+++ modules/statistics/statistics.module	3 May 2007 23:23:37 -0000
@@ -558,3 +558,12 @@ function statistics_nodeapi(&$node, $op,
 }
 
 
+
+
+/**
+ * Implentation of hook_schema()
+ */
+function statistics_schema() {
+  require_once(drupal_get_path('module', 'statistics') .'/statistics.schema');
+  return _statistics_schema();
+}
Index: modules/statistics/statistics.schema
===================================================================
RCS file: modules/statistics/statistics.schema
diff -N modules/statistics/statistics.schema
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/statistics/statistics.schema	3 May 2007 23:23:37 -0000
@@ -0,0 +1,23 @@
+<?php
+// $Id: $
+
+function _statistics_schema() {
+  $schema['accesslog'] = array(
+    'fields' => array(
+      'aid'       => array('type' => 'serial', 'not null' => TRUE),
+      'sid'       => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''),
+      'title'     => array('type' => 'varchar', 'length' => 255, 'not null' => FALSE),
+      'path'      => array('type' => 'varchar', 'length' => 255, 'not null' => FALSE),
+      'url'       => array('type' => 'varchar', 'length' => 255, 'not null' => FALSE),
+      'hostname'  => array('type' => 'varchar', 'length' => 128, 'not null' => FALSE),
+      'uid'       => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => FALSE, 'default' => 0),
+      'timer'     => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'timestamp' => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
+    ),
+    'indexes' => array('accesslog_timestamp' => array('timestamp')),
+    'primary key' => array('aid'),
+  );
+
+  return $schema;
+}
+
Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.99
diff -u -F^f -r1.99 system.install
--- modules/system/system.install	25 Apr 2007 21:34:32 -0000	1.99
+++ modules/system/system.install	3 May 2007 23:23:38 -0000
@@ -170,926 +170,10 @@ function system_requirements($phase) {
  * Implementation of hook_install().
  */
 function system_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE {access} (
-        aid int NOT NULL auto_increment,
-        mask varchar(255) NOT NULL default '',
-        type varchar(255) NOT NULL default '',
-        status tinyint NOT NULL default '0',
-        PRIMARY KEY (aid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {authmap} (
-        aid int unsigned NOT NULL auto_increment,
-        uid int NOT NULL default '0',
-        authname varchar(128) NOT NULL default '',
-        module varchar(128) NOT NULL default '',
-        PRIMARY KEY (aid),
-        UNIQUE KEY authname (authname)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {blocks} (
-        module varchar(64) DEFAULT '' NOT NULL,
-        delta varchar(32) NOT NULL default '0',
-        theme varchar(255) NOT NULL default '',
-        status tinyint DEFAULT '0' NOT NULL,
-        weight tinyint DEFAULT '0' NOT NULL,
-        region varchar(64) DEFAULT 'left' NOT NULL,
-        custom tinyint DEFAULT '0' NOT NULL,
-        throttle tinyint DEFAULT '0' NOT NULL,
-        visibility tinyint DEFAULT '0' NOT NULL,
-        pages text NOT NULL,
-        title varchar(64) DEFAULT '' NOT NULL
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {boxes} (
-        bid int NOT NULL,
-        body longtext,
-        info varchar(128) NOT NULL default '',
-        format int NOT NULL default '0',
-        PRIMARY KEY (bid),
-        UNIQUE KEY info (info)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {cache} (
-        cid varchar(255) NOT NULL default '',
-        data longblob,
-        expire int NOT NULL default '0',
-        created int NOT NULL default '0',
-        headers text,
-        serialized int(1) NOT NULL default '0',
-        PRIMARY KEY (cid),
-        INDEX expire (expire)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-      db_query("CREATE TABLE {cache_filter} (
-        cid varchar(255) NOT NULL default '',
-        data longblob,
-        expire int NOT NULL default '0',
-        created int NOT NULL default '0',
-        headers text,
-        serialized int(1) NOT NULL default '0',
-        PRIMARY KEY (cid),
-        INDEX expire (expire)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-      db_query("CREATE TABLE {cache_page} (
-        cid varchar(255) BINARY NOT NULL default '',
-        data longblob,
-        expire int NOT NULL default '0',
-        created int NOT NULL default '0',
-        headers text,
-        serialized int(1) NOT NULL default '0',
-        PRIMARY KEY (cid),
-        INDEX expire (expire)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {comments} (
-        cid int NOT NULL auto_increment,
-        pid int NOT NULL default '0',
-        nid int NOT NULL default '0',
-        uid int NOT NULL default '0',
-        subject varchar(64) NOT NULL default '',
-        comment longtext NOT NULL,
-        hostname varchar(128) NOT NULL default '',
-        timestamp int NOT NULL default '0',
-        score mediumint NOT NULL default '0',
-        status tinyint unsigned NOT NULL default '0',
-        format int NOT NULL default '0',
-        thread varchar(255) NOT NULL,
-        users longtext,
-        name varchar(60) default NULL,
-        mail varchar(64) default NULL,
-        homepage varchar(255) default NULL,
-        PRIMARY KEY (cid),
-        KEY lid (nid),
-        KEY status (status)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {node_comment_statistics} (
-        nid int unsigned NOT NULL auto_increment,
-        last_comment_timestamp int NOT NULL default '0',
-        last_comment_name varchar(60) default NULL,
-        last_comment_uid int NOT NULL default '0',
-        comment_count int unsigned NOT NULL default '0',
-        PRIMARY KEY (nid),
-        KEY node_comment_timestamp (last_comment_timestamp)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {files} (
-        fid int unsigned NOT NULL default 0,
-        nid int unsigned NOT NULL default 0,
-        filename varchar(255) NOT NULL default '',
-        filepath varchar(255) NOT NULL default '',
-        filemime varchar(255) NOT NULL default '',
-        filesize int unsigned NOT NULL default 0,
-        PRIMARY KEY (fid),
-        KEY nid (nid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {file_revisions} (
-        fid int unsigned NOT NULL default 0,
-        vid int unsigned NOT NULL default 0,
-        description varchar(255) NOT NULL default '',
-        list tinyint unsigned NOT NULL default 0,
-        PRIMARY KEY (fid, vid),
-        KEY (vid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {filter_formats} (
-        format int NOT NULL auto_increment,
-        name varchar(255) NOT NULL default '',
-        roles varchar(255) NOT NULL default '',
-        cache tinyint NOT NULL default '0',
-        PRIMARY KEY (format),
-        UNIQUE KEY (name)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {filters} (
-        format int NOT NULL default '0',
-        module varchar(64) NOT NULL default '',
-        delta tinyint DEFAULT '0' NOT NULL,
-        weight tinyint DEFAULT '0' NOT NULL,
-        INDEX (weight)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {flood} (
-        event varchar(64) NOT NULL default '',
-        hostname varchar(128) NOT NULL default '',
-        timestamp int NOT NULL default '0'
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {history} (
-        uid int NOT NULL default '0',
-        nid int NOT NULL default '0',
-        timestamp int NOT NULL default '0',
-        PRIMARY KEY (uid,nid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {menu} (
-        mid int NOT NULL default 0,
-        pid int NOT NULL default 0,
-        path varchar(255) NOT NULL default '',
-        load_functions varchar(255) NOT NULL default '',
-        to_arg_functions varchar(255) NOT NULL default '',
-        access_callback varchar(255) NOT NULL default '',
-        access_arguments text,
-        page_callback varchar(255) NOT NULL default '',
-        page_arguments text,
-        fit int NOT NULL default 0,
-        number_parts int NOT NULL default 0,
-        mleft int NOT NULL default 0,
-        mright int NOT NULL default 0,
-        visible int NOT NULL default 0,
-        parents varchar(255) NOT NULL default '',
-        depth int NOT NULL default 0,
-        has_children int NOT NULL default 0,
-        tab int NOT NULL default 0,
-        title varchar(255) NOT NULL default '',
-        title_callback varchar(255) NOT NULL default '',
-        title_arguments varchar(255) NOT NULL default '',
-        parent varchar(255) NOT NULL default '',
-        type int NOT NULL default 0,
-        block_callback varchar(255) NOT NULL default '',
-        description varchar(255) NOT NULL default '',
-        position varchar(255) NOT NULL default '',
-        link_path varchar(255) NOT NULL default '',
-        attributes varchar(255) NOT NULL default '',
-        query varchar(255) NOT NULL default '',
-        fragment varchar(255) NOT NULL default '',
-        absolute INT NOT NULL default 0,
-        html INT NOT NULL default 0,
-        PRIMARY KEY  (path),
-        KEY fit (fit),
-        KEY visible (visible),
-        KEY pid (pid),
-        KEY parent (parent)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {node} (
-        nid int unsigned NOT NULL auto_increment,
-        vid int unsigned NOT NULL default '0',
-        type varchar(32) NOT NULL default '',
-        language varchar(12) NOT NULL default '',
-        title varchar(128) NOT NULL default '',
-        uid int NOT NULL default '0',
-        status int NOT NULL default '1',
-        created int NOT NULL default '0',
-        changed int NOT NULL default '0',
-        comment int NOT NULL default '0',
-        promote int NOT NULL default '0',
-        moderate int NOT NULL default '0',
-        sticky int NOT NULL default '0',
-        PRIMARY KEY  (nid, vid),
-        UNIQUE KEY vid (vid),
-        KEY node_type (type(4)),
-        KEY node_title_type (title, type(4)),
-        KEY status (status),
-        KEY uid (uid),
-        KEY node_moderate (moderate),
-        KEY node_promote_status (promote, status),
-        KEY node_created (created),
-        KEY node_changed (changed),
-        KEY node_status_type (status, type, nid),
-        KEY nid (nid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {node_access} (
-        nid int unsigned NOT NULL default '0',
-        gid int unsigned NOT NULL default '0',
-        realm varchar(255) NOT NULL default '',
-        grant_view tinyint unsigned NOT NULL default '0',
-        grant_update tinyint unsigned NOT NULL default '0',
-        grant_delete tinyint unsigned NOT NULL default '0',
-        PRIMARY KEY (nid,gid,realm)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {node_revisions} (
-        nid int unsigned NOT NULL,
-        vid int unsigned NOT NULL,
-        uid int NOT NULL default '0',
-        title varchar(128) NOT NULL default '',
-        body longtext NOT NULL,
-        teaser longtext NOT NULL,
-        log longtext NOT NULL,
-        timestamp int NOT NULL default '0',
-        format int NOT NULL default '0',
-        PRIMARY KEY  (vid),
-        KEY nid (nid),
-        KEY uid (uid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {node_type} (
-        type varchar(32) NOT NULL,
-        name varchar(255) NOT NULL default '',
-        module varchar(255) NOT NULL,
-        description mediumtext NOT NULL,
-        help mediumtext NOT NULL,
-        has_title tinyint unsigned NOT NULL,
-        title_label varchar(255) NOT NULL default '',
-        has_body tinyint unsigned NOT NULL,
-        body_label varchar(255) NOT NULL default '',
-        min_word_count smallint unsigned NOT NULL,
-        custom tinyint NOT NULL DEFAULT '0',
-        modified tinyint NOT NULL DEFAULT '0',
-        locked tinyint NOT NULL DEFAULT '0',
-        orig_type varchar(255) NOT NULL default '',
-        PRIMARY KEY (type)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {url_alias} (
-        pid int unsigned NOT NULL auto_increment,
-        src varchar(128) NOT NULL default '',
-        dst varchar(128) NOT NULL default '',
-        language varchar(12) NOT NULL default '',
-        PRIMARY KEY (pid),
-        UNIQUE KEY dst_language (dst, language),
-        KEY src (src)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {permission} (
-        rid int unsigned NOT NULL default '0',
-        perm longtext,
-        tid int unsigned NOT NULL default '0',
-        KEY rid (rid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {role} (
-        rid int unsigned NOT NULL auto_increment,
-        name varchar(64) NOT NULL default '',
-        PRIMARY KEY (rid),
-        UNIQUE KEY name (name)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {blocks_roles} (
-        module varchar(64) NOT NULL,
-        delta varchar(32) NOT NULL,
-        rid int unsigned NOT NULL,
-        PRIMARY KEY (module, delta, rid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {sessions} (
-        uid int unsigned NOT NULL,
-        sid varchar(64) NOT NULL default '',
-        hostname varchar(128) NOT NULL default '',
-        timestamp int NOT NULL default '0',
-        cache int NOT NULL default '0',
-        session longtext,
-        KEY uid (uid),
-        PRIMARY KEY (sid),
-        KEY timestamp (timestamp)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {sequences} (
-        name varchar(255) NOT NULL default '',
-        id int unsigned NOT NULL default '0',
-        PRIMARY KEY (name)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {node_counter} (
-        nid int NOT NULL default '0',
-        totalcount bigint unsigned NOT NULL default '0',
-        daycount mediumint unsigned NOT NULL default '0',
-        timestamp int unsigned NOT NULL default '0',
-        PRIMARY KEY (nid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {system} (
-        filename varchar(255) NOT NULL default '',
-        name varchar(255) NOT NULL default '',
-        type varchar(255) NOT NULL default '',
-        owner varchar(255) NOT NULL default '',
-        status int NOT NULL default '0',
-        throttle tinyint DEFAULT '0' NOT NULL,
-        bootstrap int NOT NULL default '0',
-        schema_version smallint NOT NULL default -1,
-        weight int NOT NULL default '0',
-        info text,
-        PRIMARY KEY (filename),
-        KEY (weight)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {term_data} (
-        tid int unsigned NOT NULL auto_increment,
-        vid int unsigned NOT NULL default '0',
-        name varchar(255) NOT NULL default '',
-        description longtext,
-        weight tinyint NOT NULL default '0',
-        PRIMARY KEY (tid),
-        KEY vid (vid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {term_hierarchy} (
-        tid int unsigned NOT NULL default '0',
-        parent int unsigned NOT NULL default '0',
-        KEY tid (tid),
-        KEY parent (parent),
-        PRIMARY KEY (tid, parent)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {term_node} (
-        nid int unsigned NOT NULL default '0',
-        vid int unsigned NOT NULL default '0',
-        tid int unsigned NOT NULL default '0',
-        KEY nid (nid),
-        KEY vid (vid),
-        KEY tid (tid),
-        PRIMARY KEY (vid,tid,nid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {term_relation} (
-        tid1 int unsigned NOT NULL default '0',
-        tid2 int unsigned NOT NULL default '0',
-        KEY tid1 (tid1),
-        KEY tid2 (tid2)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {term_synonym} (
-        tid int unsigned NOT NULL default '0',
-        name varchar(255) NOT NULL default '',
-        KEY tid (tid),
-        KEY name (name(3))
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {users} (
-        uid int unsigned NOT NULL default '0',
-        name varchar(60) NOT NULL default '',
-        pass varchar(32) NOT NULL default '',
-        mail varchar(64) default '',
-        mode tinyint NOT NULL default '0',
-        sort tinyint default '0',
-        threshold tinyint default '0',
-        theme varchar(255) NOT NULL default '',
-        signature varchar(255) NOT NULL default '',
-        created int NOT NULL default '0',
-        access int NOT NULL default '0',
-        login int NOT NULL default '0',
-        status tinyint NOT NULL default '0',
-        timezone varchar(8) default NULL,
-        language varchar(12) NOT NULL default '',
-        picture varchar(255) NOT NULL DEFAULT '',
-        init varchar(64) default '',
-        data longtext,
-        PRIMARY KEY (uid),
-        UNIQUE KEY name (name),
-        KEY created (created),
-        KEY access (access)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {users_roles} (
-        uid int unsigned NOT NULL default '0',
-        rid int unsigned NOT NULL default '0',
-        PRIMARY KEY (uid, rid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {variable} (
-        name varchar(128) NOT NULL default '',
-        value longtext NOT NULL,
-        language varchar(12) NOT NULL default '',
-        PRIMARY KEY (name, language)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {vocabulary} (
-        vid int unsigned NOT NULL auto_increment,
-        name varchar(255) NOT NULL default '',
-        description longtext,
-        help varchar(255) NOT NULL default '',
-        relations tinyint unsigned NOT NULL default '0',
-        hierarchy tinyint unsigned NOT NULL default '0',
-        multiple tinyint unsigned NOT NULL default '0',
-        required tinyint unsigned NOT NULL default '0',
-        tags tinyint unsigned NOT NULL default '0',
-        module varchar(255) NOT NULL default '',
-        weight tinyint NOT NULL default '0',
-        PRIMARY KEY (vid)
-      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
-      db_query("CREATE TABLE {vocabulary_node_types} (
-        vid int unsigned NOT NULL DEFAULT '0',
-        type varchar(32) NOT NULL DEFAULT '',
-        PRIMARY KEY (vid, type)
-      ) /*!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} (
-        aid serial,
-        mask varchar(255) NOT NULL default '',
-        type varchar(255) NOT NULL default '',
-        status smallint NOT NULL default '0',
-        PRIMARY KEY (aid)
-      )");
-
-      db_query("CREATE TABLE {authmap} (
-        aid serial CHECK (aid >= 0),
-        uid int NOT NULL default '0',
-        authname varchar(128) NOT NULL default '',
-        module varchar(128) NOT NULL default '',
-        PRIMARY KEY (aid),
-        UNIQUE (authname)
-      )");
-
-      db_query("CREATE TABLE {blocks} (
-        module varchar(64) DEFAULT '' NOT NULL,
-        delta varchar(32) NOT NULL default '0',
-        theme varchar(255) NOT NULL default '',
-        status smallint DEFAULT '0' NOT NULL,
-        weight smallint DEFAULT '0' NOT NULL,
-        region varchar(64) DEFAULT 'left' NOT NULL,
-        custom smallint DEFAULT '0' NOT NULL,
-        throttle smallint DEFAULT '0' NOT NULL,
-        visibility smallint DEFAULT '0' NOT NULL,
-        pages text DEFAULT '' NOT NULL,
-        title varchar(64) DEFAULT '' NOT NULL
-      )");
-
-      db_query("CREATE TABLE {boxes} (
-        bid serial,
-        body text,
-        info varchar(128) NOT NULL default '',
-        format smallint NOT NULL default '0',
-        PRIMARY KEY (bid),
-        UNIQUE (info)
-      )");
-
-      db_query("CREATE TABLE {cache} (
-        cid varchar(255) NOT NULL default '',
-        data bytea,
-        expire int NOT NULL default '0',
-        created int NOT NULL default '0',
-        headers text,
-        serialized int(1) NOT NULL default '0',
-        PRIMARY KEY (cid)
-      )");
-      db_query("CREATE TABLE {cache_filter} (
-        cid varchar(255) NOT NULL default '',
-        data bytea,
-        expire int NOT NULL default '0',
-        created int NOT NULL default '0',
-        headers text,
-        serialized int(1) NOT NULL default '0',
-        PRIMARY KEY (cid)
-      )");
-      db_query("CREATE TABLE {cache_page} (
-        cid varchar(255) NOT NULL default '',
-        data bytea,
-        expire int NOT NULL default '0',
-        created int NOT NULL default '0',
-        headers text,
-        serialized int(1) NOT NULL default '0',
-        PRIMARY KEY (cid)
-      )");
-      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_page}_expire_idx ON {cache_page} (expire)");
-
-      db_query("CREATE TABLE {comments} (
-        cid serial,
-        pid int NOT NULL default '0',
-        nid int NOT NULL default '0',
-        uid int NOT NULL default '0',
-        subject varchar(64) NOT NULL default '',
-        comment text NOT NULL,
-        hostname varchar(128) NOT NULL default '',
-        timestamp int NOT NULL default '0',
-        score int NOT NULL default '0',
-        status smallint_unsigned NOT NULL default '0',
-        format smallint NOT NULL default '0',
-        thread varchar(255) NOT NULL,
-        users text,
-        name varchar(60) default NULL,
-        mail varchar(64) default NULL,
-        homepage varchar(255) default NULL,
-        PRIMARY KEY (cid)
-      )");
-      db_query("CREATE INDEX {comments}_nid_idx ON {comments} (nid)");
-      db_query("CREATE INDEX {comments}_status_idx ON {comments} (status)");
-
-      db_query("CREATE TABLE {node_comment_statistics} (
-        nid serial CHECK (nid >= 0),
-        last_comment_timestamp int NOT NULL default '0',
-        last_comment_name varchar(60) default NULL,
-        last_comment_uid int NOT NULL default '0',
-        comment_count int_unsigned NOT NULL default '0',
-        PRIMARY KEY (nid)
-      )");
-      db_query("CREATE INDEX {node_comment_statistics}_node_comment_timestamp_idx ON {node_comment_statistics} (last_comment_timestamp)");
-
-      db_query("CREATE TABLE {files} (
-        fid serial CHECK (fid >= 0),
-        nid int_unsigned NOT NULL default 0,
-        filename varchar(255) NOT NULL default '',
-        filepath varchar(255) NOT NULL default '',
-        filemime varchar(255) NOT NULL default '',
-        filesize int_unsigned NOT NULL default 0,
-        PRIMARY KEY (fid)
-      )");
-      db_query("CREATE INDEX {files}_nid_idx ON {files} (nid)");
-
-      db_query("CREATE TABLE {file_revisions} (
-        fid int_unsigned NOT NULL default 0,
-        vid int_unsigned NOT NULL default 0,
-        description varchar(255) NOT NULL default '',
-        list smallint_unsigned NOT NULL default 0,
-        PRIMARY KEY (fid, vid)
-      )");
-      db_query("CREATE INDEX {file_revisions}_vid_idx ON {file_revisions} (vid)");
-
-      db_query("CREATE TABLE {filter_formats} (
-        format serial,
-        name varchar(255) NOT NULL default '',
-        roles varchar(255) NOT NULL default '',
-        cache smallint NOT NULL default '0',
-        PRIMARY KEY (format),
-        UNIQUE (name)
-      )");
-
-      db_query("CREATE TABLE {filters} (
-        format int NOT NULL default '0',
-        module varchar(64) NOT NULL default '',
-        delta smallint DEFAULT '0' NOT NULL,
-        weight smallint DEFAULT '0' NOT NULL
-      )");
-      db_query("CREATE INDEX {filters}_weight_idx ON {filters} (weight)");
-
-      db_query("CREATE TABLE {flood} (
-        event varchar(64) NOT NULL default '',
-        hostname varchar(128) NOT NULL default '',
-        timestamp int NOT NULL default '0'
-      )");
-
-      db_query("CREATE TABLE {history} (
-        uid int NOT NULL default '0',
-        nid int NOT NULL default '0',
-        timestamp int NOT NULL default '0',
-        PRIMARY KEY (uid,nid)
-      )");
-
-      db_query("CREATE TABLE {menu} (
-        mid int NOT NULL default 0,
-        pid int NOT NULL default 0,
-        path varchar(255) NOT NULL default '',
-        load_functions varchar(255) NOT NULL default '',
-        to_arg_functions varchar(255) NOT NULL default '',
-        access_callback varchar(255) NOT NULL default '',
-        access_arguments text,
-        page_callback varchar(255) NOT NULL default '',
-        page_arguments text,
-        fit int NOT NULL default 0,
-        number_parts int NOT NULL default 0,
-        mleft int NOT NULL default 0,
-        mright int NOT NULL default 0,
-        visible int NOT NULL default 0,
-        parents varchar(255) NOT NULL default '',
-        depth int NOT NULL default 0,
-        has_children int NOT NULL default 0,
-        tab int NOT NULL default 0,
-        title varchar(255) NOT NULL default '',
-        title_callback varchar(255) NOT NULL default '',
-        title_arguments varchar(255) NOT NULL default '',
-        parent varchar(255) NOT NULL default '',
-        type int NOT NULL default 0,
-        block_callback varchar(255) NOT NULL default '',
-        description varchar(255) NOT NULL default '',
-        position varchar(255) NOT NULL default '',
-        link_path varchar(255) NOT NULL default '',
-        attributes varchar(255) NOT NULL default '',
-        query varchar(255) NOT NULL default '',
-        fragment varchar(255) NOT NULL default '',
-        absolute INT NOT NULL default 0,
-        html INT NOT NULL default 0,
-        PRIMARY KEY (path)
-      )");
-
-      db_query("CREATE INDEX {menu}_fit_idx ON {menu} (fit)");
-      db_query("CREATE INDEX {menu}_visible_idx ON {menu} (visible)");
-      db_query("CREATE INDEX {menu}_parent_idx ON {menu} (parent)");
-      db_query("CREATE INDEX {menu}_pid_idx ON {menu} (parent)");
-
-      db_query("CREATE TABLE {node} (
-        nid serial CHECK (nid >= 0),
-        vid int_unsigned NOT NULL default '0',
-        type varchar(32) NOT NULL default '',
-        language varchar(12) NOT NULL default '',
-        title varchar(128) NOT NULL default '',
-        uid int NOT NULL default '0',
-        status int NOT NULL default '1',
-        created int NOT NULL default '0',
-        changed int NOT NULL default '0',
-        comment int NOT NULL default '0',
-        promote int NOT NULL default '0',
-        moderate int NOT NULL default '0',
-        sticky int NOT NULL default '0',
-        PRIMARY KEY (nid, vid),
-        UNIQUE (vid)
-      )");
-      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} (
-        nid int_unsigned NOT NULL default '0',
-        gid int_unsigned NOT NULL default '0',
-        realm varchar(255) NOT NULL default '',
-        grant_view smallint_unsigned NOT NULL default '0',
-        grant_update smallint_unsigned NOT NULL default '0',
-        grant_delete smallint_unsigned NOT NULL default '0',
-        PRIMARY KEY (nid,gid,realm)
-      )");
-
-      db_query("CREATE TABLE {node_revisions} (
-        nid int_unsigned NOT NULL,
-        vid serial CHECK (vid >= 0),
-        uid int NOT NULL default '0',
-        title varchar(128) NOT NULL default '',
-        body text NOT NULL default '',
-        teaser text NOT NULL default '',
-        log text NOT NULL default '',
-        timestamp int NOT NULL default '0',
-        format int NOT NULL default '0',
-        PRIMARY KEY (vid)
-      )");
-      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} (
-        type varchar(32) NOT NULL,
-        name varchar(255) NOT NULL default '',
-        module varchar(255) NOT NULL,
-        description text NOT NULL,
-        help text NOT NULL,
-        has_title smallint_unsigned NOT NULL,
-        title_label varchar(255) NOT NULL default '',
-        has_body smallint_unsigned NOT NULL,
-        body_label varchar(255) NOT NULL default '',
-        min_word_count smallint_unsigned NOT NULL,
-        custom smallint NOT NULL DEFAULT '0',
-        modified smallint NOT NULL DEFAULT '0',
-        locked smallint NOT NULL DEFAULT '0',
-        orig_type varchar(255) NOT NULL default '',
-        PRIMARY KEY (type)
-      )");
-
-      db_query("CREATE TABLE {url_alias} (
-        pid serial CHECK (pid >= 0),
-        src varchar(128) NOT NULL default '',
-        dst varchar(128) NOT NULL default '',
-        language varchar(12) NOT NULL default '',
-        PRIMARY KEY (pid)
-      )");
-      db_query("CREATE INDEX {url_alias}_src_idx ON {url_alias} (src)");
-      db_query("CREATE UNIQUE INDEX {url_alias}_dst_language_idx ON {url_alias} (dst, language)");
-
-      db_query("CREATE TABLE {permission} (
-        rid int_unsigned NOT NULL default '0',
-        perm text,
-        tid int_unsigned NOT NULL default '0'
-      )");
-      db_query("CREATE INDEX {permission}_rid_idx ON {permission} (rid)");
-
-      db_query("CREATE TABLE {role} (
-        rid serial CHECK (rid >= 0),
-        name varchar(64) NOT NULL default '',
-        PRIMARY KEY (rid),
-        UNIQUE (name)
-      )");
-
-      db_query("CREATE TABLE {blocks_roles} (
-        module varchar(64) NOT NULL,
-        delta varchar(32) NOT NULL,
-        rid int_unsigned NOT NULL,
-        PRIMARY KEY (module, delta, rid)
-      )");
-
-      db_query("CREATE TABLE {sessions} (
-        uid int_unsigned NOT NULL,
-        sid varchar(64) NOT NULL default '',
-        hostname varchar(128) NOT NULL default '',
-        timestamp int NOT NULL default '0',
-        cache int NOT NULL default '0',
-        session text,
-        PRIMARY KEY (sid)
-      )");
-      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} (
-        nid int NOT NULL default '0',
-        totalcount bigint_unsigned NOT NULL default '0',
-        daycount int_unsigned NOT NULL default '0',
-        timestamp int_unsigned NOT NULL default '0',
-        PRIMARY KEY (nid)
-      )");
-
-      db_query("CREATE TABLE {system} (
-        filename varchar(255) NOT NULL default '',
-        name varchar(255) NOT NULL default '',
-        type varchar(255) NOT NULL default '',
-        owner varchar(255) NOT NULL default '',
-        status int NOT NULL default '0',
-        throttle smallint DEFAULT '0' NOT NULL,
-        bootstrap int NOT NULL default '0',
-        schema_version smallint NOT NULL default -1,
-        weight int NOT NULL default '0',
-        info text,
-        PRIMARY KEY (filename)
-      )");
-      db_query("CREATE INDEX {system}_weight_idx ON {system} (weight)");
-
-      db_query("CREATE TABLE {term_data} (
-        tid serial CHECK (tid >= 0),
-        vid int_unsigned NOT NULL default '0',
-        name varchar(255) NOT NULL default '',
-        description text,
-        weight smallint NOT NULL default '0',
-        PRIMARY KEY (tid)
-      )");
-      db_query("CREATE INDEX {term_data}_vid_idx ON {term_data} (vid)");
-
-      db_query("CREATE TABLE {term_hierarchy} (
-        tid int_unsigned NOT NULL default '0',
-        parent int_unsigned NOT NULL default '0',
-        PRIMARY KEY (tid, parent)
-      )");
-      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} (
-        nid int_unsigned NOT NULL default '0',
-        vid int_unsigned NOT NULL default '0',
-        tid int_unsigned NOT NULL default '0',
-        PRIMARY KEY (tid,nid,vid)
-      )");
-      db_query("CREATE INDEX {term_node}_nid_idx ON {term_node} (nid)");
-      db_query("CREATE INDEX {term_node}_vid_idx ON {term_node} (vid)");
-      db_query("CREATE INDEX {term_node}_tid_idx ON {term_node} (tid)");
-
-      db_query("CREATE TABLE {term_relation} (
-        tid1 int_unsigned NOT NULL default '0',
-        tid2 int_unsigned NOT NULL default '0'
-      )");
-      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} (
-        tid int_unsigned NOT NULL default '0',
-        name varchar(255) NOT NULL default ''
-      )");
-      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} (
-        uid serial CHECK (uid >= 0),
-        name varchar(60) NOT NULL default '',
-        pass varchar(32) NOT NULL default '',
-        mail varchar(64) default '',
-        mode smallint NOT NULL default '0',
-        sort smallint default '0',
-        threshold smallint default '0',
-        theme varchar(255) NOT NULL default '',
-        signature varchar(255) NOT NULL default '',
-        created int NOT NULL default '0',
-        access int NOT NULL default '0',
-        login int NOT NULL default '0',
-        status smallint NOT NULL default '0',
-        timezone varchar(8) default NULL,
-        language varchar(12) NOT NULL default '',
-        picture varchar(255) NOT NULL DEFAULT '',
-        init varchar(64) default '',
-        data text,
-        PRIMARY KEY (uid),
-        UNIQUE (name)
-      )");
-      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} (
-        uid int_unsigned NOT NULL default '0',
-        rid int_unsigned NOT NULL default '0',
-        PRIMARY KEY (uid, rid)
-      )");
-
-      db_query("CREATE TABLE {variable} (
-        name varchar(128) NOT NULL default '',
-        value text NOT NULL,
-        language varchar(12) NOT NULL default '',
-        PRIMARY KEY (name, language)
-      )");
-
-      db_query("CREATE TABLE {vocabulary} (
-        vid serial CHECK (vid >= 0),
-        name varchar(255) NOT NULL default '',
-        description text,
-        help varchar(255) NOT NULL default '',
-        relations smallint_unsigned NOT NULL default '0',
-        hierarchy smallint_unsigned NOT NULL default '0',
-        multiple smallint_unsigned NOT NULL default '0',
-        required smallint_unsigned NOT NULL default '0',
-        tags smallint_unsigned NOT NULL default '0',
-        module varchar(255) NOT NULL default '',
-        weight smallint NOT NULL default '0',
-        PRIMARY KEY (vid)
-      )");
-
-      db_query("CREATE TABLE {vocabulary_node_types} (
-        vid int_unsigned NOT NULL DEFAULT '0',
-        type varchar(32) NOT NULL DEFAULT '',
-        PRIMARY KEY (vid, type)
-      )");
-
-      break;
-  }
+  
+  // Create tables.
+  $schemas = module_invoke_all('schema');
+  db_create_schemas($schemas);
 
   db_query("INSERT INTO {system} (filename, name, type, owner, 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, owner, status, throttle, bootstrap, schema_version, info) VALUES ('themes/garland/page.tpl.php', 'garland', 'theme', 'themes/engines/phptemplate/phptemplate.engine', 1, 0, 0, 0, '%s')", serialize(drupal_parse_info_file('themes/garland/garland.info') + system_theme_default()));
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.472
diff -u -F^f -r1.472 system.module
--- modules/system/system.module	30 Apr 2007 17:03:28 -0000	1.472
+++ modules/system/system.module	3 May 2007 23:23:39 -0000
@@ -1273,6 +1273,7 @@ function system_themes_form_submit($form
 
   list_themes(TRUE);
   menu_rebuild();
+  drupal_load_schemas(TRUE);
   drupal_set_message(t('The configuration options have been saved.'));
   return 'admin/build/themes';
 }
@@ -2461,3 +2462,12 @@ function system_cron() {
   db_query('DELETE FROM {flood} WHERE timestamp < %d', time() - 3600);
 }
 
+
+
+/**
+ * Implentation of hook_schema()
+ */
+function system_schema() {
+  require_once(drupal_get_path('module', 'system') .'/system.schema');
+  return _system_schema();
+}
Index: modules/system/system.schema
===================================================================
RCS file: modules/system/system.schema
diff -N modules/system/system.schema
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/system/system.schema	3 May 2007 23:23:39 -0000
@@ -0,0 +1,204 @@
+<?php
+// $Id: $
+
+function _system_schema() {
+  $schema['authmap'] = array(
+    'fields' => array(
+      'aid'      => array('type' => 'serial', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE),
+      'uid'      => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'authname' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
+      'module'   => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '')
+    ),
+    'unique keys' => array('authname' => array('authname')),
+    'primary key' => array('aid'),
+  );
+
+  $schema['cache'] = array(
+    'fields' => array(
+      'cid'        => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'data'       => array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'),
+      'expire'     => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'created'    => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'headers'    => array('type' => 'text', 'not null' => FALSE),
+      'serialized' => array('type' => 'int', 'disp_width' => 1, 'not null' => TRUE, 'default' => 0)
+    ),
+    'indexes' => array('expire' => array('expire')),
+    'primary key' => array('cid'),
+  );
+
+  $schema['cache_filter'] = array(
+    'fields' => array(
+      'cid'        => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'data'       => array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'),
+      'expire'     => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'created'    => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'headers'    => array('type' => 'text', 'not null' => FALSE),
+      'serialized' => array('type' => 'int', 'disp_width' => 1, 'not null' => TRUE, 'default' => 0)
+    ),
+    'indexes' => array('expire' => array('expire')),
+    'primary key' => array('cid'),
+  );
+
+  $schema['cache_page'] = array(
+    'fields' => array(
+      'cid'        => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'data'       => array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'),
+      'expire'     => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'created'    => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'headers'    => array('type' => 'text', 'not null' => FALSE),
+      'serialized' => array('type' => 'int', 'disp_width' => 1, 'not null' => TRUE, 'default' => 0)
+    ),
+    'indexes' => array('expire' => array('expire')),
+    'primary key' => array('cid'),
+  );
+
+  $schema['files'] = array(
+    'fields' => array(
+      'fid'      => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'nid'      => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'filename' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'filepath' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'filemime' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'filesize' => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
+    ),
+    'indexes' => array('nid' => array('nid')),
+    'primary key' => array('fid'),
+  );
+
+  $schema['file_revisions'] = array(
+    'fields' => array(
+      'fid'         => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'vid'         => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'description' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'list'        => array('type' => 'int', 'disp_width' => 3, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny')
+    ),
+    'primary key' => array('fid', 'vid'),
+    'indexes' => array('vid' => array('vid')),
+  );
+
+  $schema['flood'] = array(
+    'fields' => array(
+      'event'     => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''),
+      'hostname'  => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
+      'timestamp' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)
+    ),
+  );
+
+  $schema['history'] = array(
+    'fields' => array(
+      'uid'       => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'nid'       => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'timestamp' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)
+    ),
+    'primary key' => array('uid', 'nid'),
+  );
+
+  $schema['menu'] = array(
+    'fields' => array(
+      'mid'              => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'pid'              => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'path'             => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'load_functions'   => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'to_arg_functions' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'access_callback'  => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'access_arguments' => array('type' => 'text', 'not null' => FALSE),
+      'page_callback'    => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'page_arguments'   => array('type' => 'text', 'not null' => FALSE),
+      'fit'              => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'number_parts'     => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'mleft'            => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'mright'           => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'visible'          => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'parents'          => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'depth'            => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'has_children'     => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'tab'              => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'title'            => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'title_callback'   => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'title_arguments'  => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'parent'           => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'type'             => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'block_callback'   => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'description'      => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'position'         => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'link_path'        => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'attributes'       => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'query'            => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'fragment'         => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'absolute'         => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'html'             => array('type' => 'int', 'not null' => TRUE, 'default' => 0)
+    ),
+    'indexes' => array(
+      'fit'     => array('fit'),
+      'parent'  => array('parent'),
+      'pid'     => array('pid'),
+      'visible' => array('visible')
+    ),
+    'primary key' => array('path'),
+  );
+
+  $schema['sequences'] = array(
+    'fields' => array(
+      'name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'id'   => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
+    ),
+    'primary key' => array('name'),
+  );
+
+  $schema['sessions'] = array(
+    'fields' => array(
+      'uid'       => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE),
+      'sid'       => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''),
+      'hostname'  => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
+      'timestamp' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'cache'     => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'session'   => array('type' => 'text', 'not null' => FALSE, 'size' => 'big')
+    ),
+    'primary key' => array('sid'),
+    'indexes' => array(
+      'timestamp' => array('timestamp'),
+      'uid'       => array('uid')
+    ),
+  );
+
+  $schema['system'] = array(
+    'fields' => array(
+      'filename'       => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'name'           => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'type'           => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'owner'          => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'status'         => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'throttle'       => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'bootstrap'      => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'schema_version' => array('type' => 'int', 'disp_width' => 6, 'not null' => TRUE, 'default' => -1, 'size' => 'small'),
+      'weight'         => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'info'           => array('type' => 'text', 'not null' => FALSE)
+    ),
+    'primary key' => array('filename'),
+    'indexes' => array('weight' => array('weight')),
+  );
+
+  $schema['url_alias'] = array(
+    'fields' => array(
+      'pid'      => array('type' => 'serial', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE),
+      'src'      => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
+      'dst'      => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
+      'language' => array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => '')
+    ),
+    'unique keys' => array('dst_language' => array('dst', 'language')),
+    'primary key' => array('pid'),
+    'indexes' => array('src' => array('src')),
+  );
+
+  $schema['variable'] = array(
+    'fields' => array(
+      'name'     => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
+      'value'    => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'),
+      'language' => array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => '')
+    ),
+    'primary key' => array('name', 'language'),
+  );
+
+  return $schema;
+}
+
Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.353
diff -u -F^f -r1.353 taxonomy.module
--- modules/taxonomy/taxonomy.module	30 Apr 2007 17:03:28 -0000	1.353
+++ modules/taxonomy/taxonomy.module	3 May 2007 23:23:40 -0000
@@ -1559,3 +1559,12 @@ function taxonomy_implode_tags($tags, $v
   }
   return implode(', ', $typed_tags);
 }
+
+
+/**
+ * Implentation of hook_schema()
+ */
+function taxonomy_schema() {
+  require_once(drupal_get_path('module', 'taxonomy') .'/taxonomy.schema');
+  return _taxonomy_schema();
+}
Index: modules/taxonomy/taxonomy.schema
===================================================================
RCS file: modules/taxonomy/taxonomy.schema
diff -N modules/taxonomy/taxonomy.schema
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/taxonomy/taxonomy.schema	3 May 2007 23:23:40 -0000
@@ -0,0 +1,96 @@
+<?php
+// $Id: $
+
+function _taxonomy_schema() {
+  $schema['term_data'] = array(
+    'fields' => array(
+      'tid'         => array('type' => 'serial', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE),
+      'vid'         => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'name'        => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'description' => array('type' => 'text', 'not null' => FALSE, 'size' => 'big'),
+      'weight'      => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny')
+    ),
+    'primary key' => array('tid'),
+    'indexes' => array('vid' => array('vid')),
+  );
+
+  $schema['term_hierarchy'] = array(
+    'fields' => array(
+      'tid'    => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'parent' => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
+    ),
+    'indexes' => array(
+      'parent' => array('parent'),
+      'tid'    => array('tid')
+    ),
+    'primary key' => array('tid', 'parent'),
+  );
+
+  $schema['term_node'] = array(
+    'fields' => array(
+      'nid' => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'vid' => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'tid' => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
+    ),
+    'indexes' => array(
+      'nid' => array('nid'),
+      'tid' => array('tid'),
+      'vid' => array('vid')
+    ),
+    'primary key' => array(
+      'vid',
+      'tid',
+      'nid'
+    ),
+  );
+
+  $schema['term_relation'] = array(
+    'fields' => array(
+      'tid1' => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'tid2' => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
+    ),
+    'indexes' => array(
+      'tid1' => array('tid1'),
+      'tid2' => array('tid2')
+    ),
+  );
+
+  $schema['term_synonym'] = array(
+    'fields' => array(
+      'tid'  => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')
+    ),
+    'indexes' => array(
+      'name' => array('name'),
+      'tid'  => array('tid')
+    ),
+  );
+
+  $schema['vocabulary'] = array(
+    'fields' => array(
+      'vid'         => array('type' => 'serial', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE),
+      'name'        => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'description' => array('type' => 'text', 'not null' => FALSE, 'size' => 'big'),
+      'help'        => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'relations'   => array('type' => 'int', 'disp_width' => 3, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'hierarchy'   => array('type' => 'int', 'disp_width' => 3, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'multiple'    => array('type' => 'int', 'disp_width' => 3, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'required'    => array('type' => 'int', 'disp_width' => 3, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'tags'        => array('type' => 'int', 'disp_width' => 3, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'module'      => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'weight'      => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny')
+    ),
+    'primary key' => array('vid'),
+  );
+
+  $schema['vocabulary_node_types'] = array(
+    'fields' => array(
+      'vid'  => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'type' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => '')
+    ),
+    'primary key' => array('vid', 'type'),
+  );
+
+  return $schema;
+}
+
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.777
diff -u -F^f -r1.777 user.module
--- modules/user/user.module	30 Apr 2007 17:03:29 -0000	1.777
+++ modules/user/user.module	3 May 2007 23:23:42 -0000
@@ -2851,3 +2851,12 @@ function theme_user_signature($signature
   return $output;
 }
 
+
+
+/**
+ * Implentation of hook_schema()
+ */
+function user_schema() {
+  require_once(drupal_get_path('module', 'user') .'/user.schema');
+  return _user_schema();
+}
Index: modules/user/user.schema
===================================================================
RCS file: modules/user/user.schema
diff -N modules/user/user.schema
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/user/user.schema	3 May 2007 23:23:42 -0000
@@ -0,0 +1,72 @@
+<?php
+// $Id: $
+
+function _user_schema() {
+  $schema['access'] = array(
+    'fields' => array(
+      'aid'    => array('type' => 'serial', 'not null' => TRUE),
+      'mask'   => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'type'   => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'status' => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny')
+    ),
+    'primary key' => array('aid'),
+  );
+
+  $schema['permission'] = array(
+    'fields' => array(
+      'rid'  => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'perm' => array('type' => 'text', 'not null' => FALSE, 'size' => 'big'),
+      'tid'  => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
+    ),
+    'indexes' => array('rid' => array('rid')),
+  );
+
+  $schema['role'] = array(
+    'fields' => array(
+      'rid'  => array('type' => 'serial', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE),
+      'name' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => '')
+    ),
+    'unique keys' => array('name' => array('name')),
+    'primary key' => array('rid'),
+  );
+
+  $schema['users'] = array(
+    'fields' => array(
+      'uid'       => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'name'      => array('type' => 'varchar', 'length' => 60, 'not null' => TRUE, 'default' => ''),
+      'pass'      => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''),
+      'mail'      => array('type' => 'varchar', 'length' => 64, 'not null' => FALSE, 'default' => ''),
+      'mode'      => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'sort'      => array('type' => 'int', 'disp_width' => 4, 'not null' => FALSE, 'default' => 0, 'size' => 'tiny'),
+      'threshold' => array('type' => 'int', 'disp_width' => 4, 'not null' => FALSE, 'default' => 0, 'size' => 'tiny'),
+      'theme'     => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'signature' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'created'   => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'access'    => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'login'     => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'status'    => array('type' => 'int', 'disp_width' => 4, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
+      'timezone'  => array('type' => 'varchar', 'length' => 8, 'not null' => FALSE),
+      'language'  => array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''),
+      'picture'   => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'init'      => array('type' => 'varchar', 'length' => 64, 'not null' => FALSE, 'default' => ''),
+      'data'      => array('type' => 'text', 'not null' => FALSE, 'size' => 'big')
+    ),
+    'indexes' => array(
+      'access'  => array('access'),
+      'created' => array('created')
+    ),
+    'unique keys' => array('name' => array('name')),
+    'primary key' => array('uid'),
+  );
+
+  $schema['users_roles'] = array(
+    'fields' => array(
+      'uid' => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'rid' => array('type' => 'int', 'disp_width' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
+    ),
+    'primary key' => array('uid', 'rid'),
+  );
+
+  return $schema;
+}
+
