hosting_task.install in Hosting 5
File
task/hosting_task.install
View source
<?php
function hosting_task_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {hosting_task} (\n vid int(10) unsigned NOT NULL default '0',\n nid int(10) unsigned NOT NULL default '0',\n task_type longtext,\n rid int(11) NOT NULL default '0',\n task_status int(11) default NULL,\n executed int(11) default NULL,\n PRIMARY KEY (vid)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {hosting_task_arguments} (\n vid int(10) unsigned NOT NULL default '0',\n nid int(10) unsigned NOT NULL default '0',\n name longtext,\n value longtext\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {hosting_task_log} (\n lid int NOT NULL auto_increment,\n vid int NOT NULL default '0',\n type varchar(16) NOT NULL default '',\n message longtext NOT NULL,\n error longtext NOT NULL default '',\n timestamp int NOT NULL default '0',\n PRIMARY KEY (lid),\n KEY (type)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {hosting_task_queue} (\n nid int NOT NULL default '0',\n timestamp int NOT NULL default '0',\n status tinyint unsigned NOT NULL default 0,\n PRIMARY KEY (nid)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
break;
}
}
function hosting_task_update_1() {
$ret = array();
$ret[] = update_sql("ALTER TABLE {hosting_task_log} \n ADD COLUMN error longtext NOT NULL default ''");
$ret[] = update_sql("ALTER TABLE {hosting_task_log} \n DROP COLUMN severity");
return $ret;
}
function hosting_task_update_2() {
$ret = array();
variable_set('hosting_dispatch_enabled', FALSE);
db_query("UPDATE {hosting_task_queue} SET status = 100 WHERE status = 0");
db_query("UPDATE {hosting_task_queue} SET status = 0 WHERE status <> 100");
db_query("UPDATE {hosting_task_queue} SET status = 1 WHERE status = 100");
variable_set('hosting_dispatch_enabled', TRUE);
return $ret;
}