diff --git a/bin/dbmaint.php b/bin/dbmaint.php index ed9a2a2..49777c6 100644 --- a/bin/dbmaint.php +++ b/bin/dbmaint.php @@ -2,51 +2,57 @@ require_once('../config/dmsDefaults.php'); -print _kt('DB Maintenance') . "...\n\n"; - $action = 'check'; $sqlaction = 'check table'; if ($argc > 0) { foreach($argv as $arg) { - $arg=strtolower($arg); - switch ($arg) + $action=strtolower($arg); + switch ($action) { - case 'check': case 'repair': + $sqlaction='repair table'; + break; case 'optimize': - $sqlaction="$arg table"; - $action = $arg; + $sqlaction='optimize table'; break; case 'help': print "Usage: dbmaint.php repair|check|optimize\n"; exit; + case 'check': + default: + $action = 'check'; + $sqlaction='check table'; + break; } } } -print '* ' . sprintf(_kt("Action selected: %s"), $action) . "\n\n"; +$default->log->info("DB Maintenance... \nAction selected: {$action}"); $sql = "show tables"; $tables = DBUtil::getResultArray($sql); -foreach($tables as $table) -{ - $key = array_keys($table); - - $tablename=$table[$key[0]]; - $sql = "$sqlaction $tablename"; - $result = DBUtil::getOneResult($sql); - if (PEAR::isError($result)) - { - print sprintf(_kt("Attempted: %s"), $sql) . "\n"; - print sprintf(_kt(' *: %s'), $result->getMessage()) . "\n"; - continue; - } - print sprintf(_kt("Running: %s - %s"), $sql, $result['Msg_text']) . "\n"; +if(!empty($tables)){ + foreach($tables as $table) + { + $key = array_keys($table); + + $tablename=$table[$key[0]]; + $sql = "$sqlaction $tablename;"; + $result = DBUtil::getOneResult($sql); + + if (PEAR::isError($result)) + { + $default->log->error('Attempted: '.$sql); + $default->log->error(' *: '.$result->getMessage()); + continue; + } + $default->log->info('Running: '.$sql .' - '. $result['Msg_text']); + } } -print _kt('Done.') . "\n"; +$default->log->info('Done.'); ?> \ No newline at end of file diff --git a/sql/mysql/install/data.sql b/sql/mysql/install/data.sql index b9b7b55..00dae68 100644 --- a/sql/mysql/install/data.sql +++ b/sql/mysql/install/data.sql @@ -798,7 +798,8 @@ INSERT INTO `scheduler_tasks` VALUES (1,'Indexing','search2/indexing/bin/cronIndexer.php','',0,'1min','2007-10-01',NULL,0,'system'), (2,'Index Migration','search2/indexing/bin/cronMigration.php','',0,'5mins','2007-10-01',NULL,0,'system'), (3,'Index Optimisation','search2/indexing/bin/optimise.php','',0,'weekly','2007-10-01',NULL,0,'system'), -(4,'Periodic Document Expunge','bin/expungeall.php','',0,'weekly','2007-10-01',NULL,0,'disabled'); +(4,'Periodic Document Expunge','bin/expungeall.php','',0,'weekly','2007-10-01',NULL,0,'disabled'), +(5,'Database Maintenance','bin/dbmaint.php','optimize',0,'monthly','2007-10-01',NULL,0,'disabled'); /*!40000 ALTER TABLE `scheduler_tasks` ENABLE KEYS */; UNLOCK TABLES; diff --git a/sql/mysql/upgrade/3.5.2/scheduler_tasks.sql b/sql/mysql/upgrade/3.5.2/scheduler_tasks.sql index 87af221..4f38e5e 100644 --- a/sql/mysql/upgrade/3.5.2/scheduler_tasks.sql +++ b/sql/mysql/upgrade/3.5.2/scheduler_tasks.sql @@ -2,4 +2,10 @@ ALTER TABLE `scheduler_tasks` ADD `status` ENUM( 'enabled', 'disabled', 'sy UPDATE `scheduler_tasks` SET `status` = 'system' WHERE `task` = 'Indexing' OR `task` = 'Index Migration' OR `task` = 'Index Optimisation'; -INSERT INTO `scheduler_tasks` VALUES (4,'Periodic Document Expunge','bin/expungeall.php','',0,'weekly','2007-10-01',NULL,0,'disabled'); \ No newline at end of file +select @id:=ifnull(max(id),0)+1 from scheduler_tasks; +INSERT INTO `scheduler_tasks` VALUES (id,'Periodic Document Expunge','bin/expungeall.php','',0,'weekly','2007-10-01',NULL,0,'disabled'); + +select @id:=max(id)+1 from scheduler_tasks; +INSERT INTO `scheduler_tasks` VALUES (id,'Database Maintenance','bin/dbmaint.php','optimize',0,'monthly','2007-10-01',NULL,0,'disabled'); + +UPDATE zseq_scheduler_tasks set id=@id; \ No newline at end of file