summaryrefslogtreecommitdiff
path: root/modules/dblog
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2007-05-25 12:46:46 +0000
committerDries Buytaert <dries@buytaert.net>2007-05-25 12:46:46 +0000
commit3cafffe63f70f418d0b6ca32ac5e0f3e27dceb41 (patch)
treecd59a40556a084f35b7b5a3bc3caa50874087541 /modules/dblog
parentae762838c0e92bded86370103df4583874c50da7 (diff)
downloadbrdo-3cafffe63f70f418d0b6ca32ac5e0f3e27dceb41.tar.gz
brdo-3cafffe63f70f418d0b6ca32ac5e0f3e27dceb41.tar.bz2
- Killer patch #144765 by bjaspan, frando et al: schema API 1 hits core. Oh, behave.
Diffstat (limited to 'modules/dblog')
-rw-r--r--modules/dblog/dblog.install45
-rw-r--r--modules/dblog/dblog.schema25
2 files changed, 29 insertions, 41 deletions
diff --git a/modules/dblog/dblog.install b/modules/dblog/dblog.install
index 44961f7b1..b2f0ac97a 100644
--- a/modules/dblog/dblog.install
+++ b/modules/dblog/dblog.install
@@ -5,51 +5,14 @@
* 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_install_schema('dblog');
}
/**
* Implementation of hook_uninstall().
*/
function dblog_uninstall() {
- db_query('DROP TABLE {watchdog}');
+ // Remove tables.
+ drupal_uninstall_schema('dblog');
}
diff --git a/modules/dblog/dblog.schema b/modules/dblog/dblog.schema
new file mode 100644
index 000000000..785f1d98f
--- /dev/null
+++ b/modules/dblog/dblog.schema
@@ -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', '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;
+}
+