Location: PHPKode > projects > OpenCollab > openc/inc.update.php
<?php
$UPDATE_SQL = array();
$UPDATE_SQL[0] = array('type' => 'newfield', 'table' => 'co_groups', 'field' => 'cg_closed', 'query' => 'ALTER TABLE  `co_groups` ADD  `cg_closed` TINYINT NOT NULL');
$UPDATE_SQL[1] = array('type' => 'newfield', 'table' => 'co_groups', 'field' => 'cg_keine_mitglieder', 'query' => 'ALTER TABLE  `co_groups` ADD  `cg_keine_mitglieder` TINYINT NOT NULL');
$UPDATE_SQL[2] = array('type' => 'newtable', 'table' => 'co_groups_apps', 'query' => 'CREATE TABLE `co_groups_apps` (`ga_pk` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY ,`ga_cg_fk` BIGINT NOT NULL ,`ga_ca_fk` BIGINT NOT NULL) ENGINE = MYISAM');
$UPDATE_SQL[3] = array('type' => 'newfield', 'table' => 'co_apps', 'field' => 'ca_url_groupapp', 'query' => 'ALTER TABLE  `co_apps` ADD  `ca_url_groupapp` VARCHAR( 255 ) NOT NULL AFTER  `ca_url`');
$UPDATE_SQL[4] = array('type' => 'newfield', 'table' => 'co_publisher_comment', 'field' => 'pc_file', 'query' => 'ALTER TABLE  `co_publisher_comment` ADD  `pc_file` TEXT NOT NULL ');
$UPDATE_SQL[5] = array('type' => 'newfield', 'table' => 'co_apps', 'field' => 'ca_head', 'query' => 'ALTER TABLE `co_apps` ADD `ca_head` TEXT NOT NULL AFTER `ca_publisher_url` ');
$UPDATE_SQL[6] = array('type' => 'newfield', 'table' => 'co_groups_member', 'field' => 'gm_disablenotify', 'query' => 'ALTER TABLE `co_groups_member` ADD `gm_disablenotify` TINYINT NOT NULL');

$UPDATE_SQL[7] = array('type' => 'newtable', 'table' => 'co_publisher_search', 'query' => 'CREATE TABLE IF NOT EXISTS `co_publisher_search` (`ps_pk` bigint(20) NOT NULL auto_increment,`ps_text` varchar(255) NOT NULL,`ps_count` int(11) NOT NULL,PRIMARY KEY  (`ps_pk`),KEY `ps_text` (`ps_text`)) ENGINE=MyISAM  DEFAULT CHARSET=utf8');
$UPDATE_SQL[8] = array('type' => 'newtable', 'table' => 'co_publisher_search2id', 'query' => 'CREATE TABLE IF NOT EXISTS `co_publisher_search2id` (`cp_fk` int(11) NOT NULL,`ps_fk` int(11) NOT NULL,`ps_pos` int(11) NOT NULL,KEY `cp_fk` (`cp_fk`,`ps_fk`)) ENGINE=MyISAM DEFAULT CHARSET=utf8');

$UPDATE_SQL[9] = array('type' => 'newfield', 'table' => 'co_groups', 'field' => 'cg_or_tags', 'query' => 'ALTER TABLE `co_groups` ADD `cg_or_tags` VARCHAR(255) NOT NULL');

$UPDATE_SQL[10] = array('type' => 'newtable', 'table' => 'co_translation', 'query' => 'CREATE TABLE IF NOT EXISTS `co_translation` (`co_pk` bigint(20) NOT NULL auto_increment,`co_de` varchar(255) NOT NULL,`co_en` varchar(255) NOT NULL,PRIMARY KEY  (`co_pk`),KEY `co_de` (`co_de`) ) ENGINE=MyISAM  DEFAULT CHARSET=utf8');
$UPDATE_SQL[11] = array('type' => 'newfield', 'table' => 'co_apps', 'field' => 'ca_masterapp', 'query' => 'ALTER TABLE `co_apps` ADD `ca_masterapp` TINYINT NOT NULL'); 
$UPDATE_SQL[12] = array('type' => 'newfield', 'table' => 'co_publisher_comment','field'=>'pc_pc_fk', 'query'=>'ALTER TABLE `co_publisher_comment` ADD `pc_pc_fk` BIGINT NOT NULL AFTER `pc_cp_fk`'); 

$UPDATE_SQL[13] = array('type' => 'newfield', 'table' => 'co_publisher','field'=>'cp_closed', 'query'=>'ALTER TABLE `co_publisher` ADD `cp_closed` VARCHAR( 255 ) NOT NULL ');
$UPDATE_SQL[14] = array('type' => 'newfield', 'table' => 'co_publisher','field'=>'cp_final', 'query'=>'ALTER TABLE `co_publisher` ADD `cp_final` tinyint NOT NULL ');
$UPDATE_SQL[15] = array('type' => 'newfield', 'table' => 'co_publisher','field'=>'cp_deleted', 'query'=>'ALTER TABLE `co_publisher` ADD `cp_deleted` int(11) NOT NULL ');

$STEP = -1;
if(file_exists($update_fn.'.count')) $STEP = getFile($update_fn.'.count');
#include_once(projectPath.'/inc.update_sql.php');
for($i=0;$i<count($UPDATE_SQL);$i++) {
	// {{{
	
	if($i<=$STEP) continue;
	
	if($UPDATE_SQL[$i]['type']=='newfield') {
		// {{{
		if(!$fast->DC->fieldExists($UPDATE_SQL[$i]['table'], $UPDATE_SQL[$i]['field'])) {
			$fast->DC->sendQuery($UPDATE_SQL[$i]['query']);
			addFile($update_fn,date("Y-m-d H:i:s")."\t"."UPDATE-SQL-STEP ".$i);
		}
		setFile($update_fn.'.count', $i);
		// }}}
	}
	
	if($UPDATE_SQL[$i]['type']=='newtable') {
		// {{{
		if(!$fast->DC->tableExists($UPDATE_SQL[$i]['table'])) {
			$fast->DC->sendQuery($UPDATE_SQL[$i]['query']);
			addFile($update_fn,date("Y-m-d H:i:s")."\t". "UPDATE-SQL-STEP ".$i);
		}
		setFile($update_fn.'.count', $i);
		// }}}
	}
	// }}}
}


?>
Return current item: OpenCollab