Adding force to update routine

- Introduced Cache::NEVER Lock (never expiring lock)
- Force flag for dbstructure update
- Moving the business logic to central place in Update class
This commit is contained in:
Philipp Holzer 2018-10-29 10:16:07 +01:00
parent f2ec963b95
commit 270e817954
No known key found for this signature in database
GPG key ID: 517BE60E2CE5C8A5
9 changed files with 141 additions and 104 deletions

View file

@ -25,7 +25,7 @@ class DatabaseStructure extends \Asika\SimpleConsole\Console
$help = <<<HELP
console dbstructure - Performs database updates
Usage
bin/console dbstructure <command> [-h|--help|-?] [-v]
bin/console dbstructure <command> [-h|--help|-?] |-f|--force] [-v]
Commands
dryrun Show database update schema queries without running them
@ -36,14 +36,13 @@ Commands
Options
-h|--help|-? Show help information
-v Show more debug information.
-f|--force Force the command in case of "update" (Ignore failed updates/running updates)
HELP;
return $help;
}
protected function doExecute()
{
$a = get_app();
if ($this->getOption('v')) {
$this->out('Class: ' . __CLASS__);
$this->out('Arguments: ' . var_export($this->args, true));
@ -70,34 +69,8 @@ HELP;
$output = DBStructure::update(true, false);
break;
case "update":
$build = Core\Config::get('system', 'build');
if (empty($build)) {
Core\Config::set('system', 'build', DB_UPDATE_VERSION);
$build = DB_UPDATE_VERSION;
}
$stored = intval($build);
$current = intval(DB_UPDATE_VERSION);
// run the pre_update_nnnn functions in update.php
for ($x = $stored; $x < $current; $x ++) {
$r = Update::runUpdateFunction($x, 'pre_update');
if (!$r) {
break;
}
}
$output = DBStructure::update(true, true);
// run the update_nnnn functions in update.php
for ($x = $stored; $x < $current; $x ++) {
$r = Update::runUpdateFunction($x, 'update');
if (!$r) {
break;
}
}
Core\Config::set('system', 'build', DB_UPDATE_VERSION);
$force = $this->getOption(['f', 'force'], false);
$output = Update::run($force, true, false);
break;
case "dumpsql":
ob_start();