diff options
author | Dries Buytaert <dries@buytaert.net> | 2007-05-25 12:46:46 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2007-05-25 12:46:46 +0000 |
commit | 3cafffe63f70f418d0b6ca32ac5e0f3e27dceb41 (patch) | |
tree | cd59a40556a084f35b7b5a3bc3caa50874087541 /modules/contact | |
parent | ae762838c0e92bded86370103df4583874c50da7 (diff) | |
download | brdo-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/contact')
-rw-r--r-- | modules/contact/contact.install | 33 | ||||
-rw-r--r-- | modules/contact/contact.schema | 20 |
2 files changed, 25 insertions, 28 deletions
diff --git a/modules/contact/contact.install b/modules/contact/contact.install index b24c4ca51..fe31ca327 100644 --- a/modules/contact/contact.install +++ b/modules/contact/contact.install @@ -5,40 +5,17 @@ * 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_install_schema('contact'); } /** * Implementation of hook_uninstall(). */ function contact_uninstall() { - db_query('DROP TABLE {contact}'); + // Remove tables. + drupal_uninstall_schema('contact'); + variable_del('contact_default_status'); variable_del('contact_form_information'); variable_del('contact_hourly_threshold'); diff --git a/modules/contact/contact.schema b/modules/contact/contact.schema new file mode 100644 index 000000000..f77f6a27c --- /dev/null +++ b/modules/contact/contact.schema @@ -0,0 +1,20 @@ +<?php +// $Id$ + +function contact_schema() { + $schema['contact'] = array( + 'fields' => array( + 'cid' => array('type' => 'serial', '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', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'), + 'selected' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny') + ), + 'unique keys' => array('category' => array('category')), + 'primary key' => array('cid'), + ); + + return $schema; +} + |