View source
<?php
function contemplate_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {contemplate} (\n type varchar(32) NOT NULL default '',\n teaser text NOT NULL,\n body text NOT NULL,\n rss text NOT NULL,\n enclosure varchar(128) NOT NULL,\n flags int(8) unsigned NOT NULL default '7',\n KEY type (type)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
db_query("CREATE TABLE {contemplate_files} (\n site varchar(255) NOT NULL,\n `data` longblob NOT NULL,\n UNIQUE KEY site (site(255))\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
db_query("UPDATE {system} SET weight = 10 WHERE name = 'contemplate'");
break;
case 'pgsql':
db_query("CREATE TABLE {contemplate} (\n type varchar(32) NOT NULL default '',\n teaser text NOT NULL,\n body text NOT NULL,\n rss text NOT NULL,\n enclosure varchar(128) NOT NULL,\n flags int_unsigned NOT NULL default '0',\n PRIMARY KEY (type)\n );");
db_query("CREATE TABLE {contemplate_files} (\n site varchar(255) NOT NULL,\n data bytea NOT NULL\n );");
db_query("CREATE UNIQUE INDEX {contemplate_files}_site_idx ON {contemplate_files} (site)");
db_query("UPDATE {system} SET weight = 10 WHERE name = 'contemplate'");
break;
}
drupal_set_message(t('Database tables for ConTemplate module have been installed.'));
}
function contemplate_update_1() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql('ALTER TABLE {contemplate} ADD rss text NOT NULL');
$ret[] = update_sql('ALTER TABLE {contemplate} ADD enclosure varchar(128) NOT NULL');
$ret[] = update_sql("ALTER TABLE {contemplate} ADD flags int(8) unsigned NOT NULL default '7'");
break;
}
return $ret;
}
function contemplate_update_2() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql('CREATE TABLE {contemplate_files} (
site varchar(255) NOT NULL,
data longblob NOT NULL,
UNIQUE KEY site (site(255))
) /*!40100 DEFAULT CHARACTER SET utf8 */;');
break;
}
return $ret;
}
function contemplate_uninstall() {
db_query('DROP TABLE {contemplate}');
db_query('DROP TABLE {contemplate_files}');
drupal_set_message(t('The ConTemplate tables have been removed from the database'));
}