$sql='CREATE TABLE IF NOT EXISTS `event_blacklists` ( `id` int(11) NOT NULL AUTO_INCREMENT, `event_uuid` varchar(40) COLLATE utf8_bin NOT NULL, `created` datetime NOT NULL, PRIMARY KEY (`id`), `event_info` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, `event_orgc` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ;';
break;
case'addEventBlacklistsContext':
$sql='ALTER TABLE `event_blacklists` ADD `event_orgc` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL , ADD `event_info` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, ADD `comment` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ;';
'title'=>'Successfuly executed the SQL query for '.$command,
'change'=>'The executed SQL query was: '.$sql
));
}catch(Exception$e){
$this->Log->create();
$this->Log->save(array(
'org'=>'SYSTEM',
'model'=>'Server',
'model_id'=>0,
'email'=>'SYSTEM',
'action'=>'update_database',
'user_id'=>0,
'title'=>'Issues executing the SQL query for '.$command,
'change'=>'The executed SQL query was: '.$sql.PHP_EOL.' The returned error is: '.$e->getMessage()
));
}
$this->__cleanCacheFiles();
returntrue;
}
privatefunction__dropIndex($table,$field){
$this->Log=ClassRegistry::init('Log');
$indexCheck="SELECT INDEX_NAME FROM INFORMATION_SCHEMA.STATISTICS WHERE table_schema=DATABASE() AND table_name='".$table."' AND index_name LIKE '".$field."%'";
$indexCheckResult=$this->query($indexCheck);
foreach($indexCheckResultas$icr){
$dropIndex='ALTER TABLE '.$table.' DROP INDEX '.$icr['STATISTICS']['INDEX_NAME'];
$result=true;
try{
$this->query($dropIndex);
}catch(Exception$e){
$result=false;
}
$this->Log->create();
$this->Log->save(array(
'org'=>'SYSTEM',
'model'=>'Server',
'model_id'=>0,
'email'=>'SYSTEM',
'action'=>'update_database',
'user_id'=>0,
'title'=>($result?'Removed index ':'Failed to remove index ').$icr['STATISTICS']['INDEX_NAME'].' from '.$table,
'change'=>($result?'Removed index ':'Failed to remove index ').$icr['STATISTICS']['INDEX_NAME'].' from '.$table,