context_ui.install in Context 5
File
context_ui/context_ui.install
View source
<?php
function context_ui_install() {
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
db_query("CREATE TABLE {context_ui} (\n cid INT(10) NOT NULL,\n system INT(1) NOT NULL,\n status INT(1) NOT NULL,\n namespace VARCHAR(64) NOT NULL,\n attribute VARCHAR(64) NOT NULL,\n value VARCHAR(64),\n PRIMARY KEY(cid),\n KEY (system, namespace, attribute, value)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */");
db_query("CREATE TABLE {context_ui_item} (\n type VARCHAR(32) NOT NULL,\n id VARCHAR(255) NOT NULL,\n cid INT(10) NOT NULL,\n KEY(id, type, cid)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */");
db_query("CREATE TABLE {context_ui_block} (\n module VARCHAR(64) NOT NULL,\n delta VARCHAR(32) NOT NULL,\n region VARCHAR(64) NOT NULL,\n weight TINYINT(4) NOT NULL,\n cid INT(10) NOT NULL, \n KEY(module, delta, region, cid)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */");
break;
}
}
function context_ui_update_1() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {context_ui} MODIFY COLUMN space VARCHAR(64) NOT NULL");
$ret[] = update_sql("ALTER TABLE {context_ui} MODIFY COLUMN `key` VARCHAR(64) NOT NULL");
$ret[] = update_sql("ALTER TABLE {context_ui} MODIFY COLUMN value VARCHAR(64) NOT NULL");
break;
}
return $ret;
}
function context_ui_update_2() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {context_ui} CHANGE COLUMN space namespace VARCHAR(64) NOT NULL");
$ret[] = update_sql("ALTER TABLE {context_ui} CHANGE COLUMN `key` attribute VARCHAR(64) NOT NULL");
break;
}
return $ret;
}
function context_ui_uninstall() {
db_query('DROP TABLE {context_ui}');
db_query('DROP TABLE {context_ui_item}');
db_query('DROP TABLE {context_ui_block}');
}