X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FConsole%2FDatabaseStructure.php;h=dededa9b3a4321e09fcd3ea31ea6d07c6f026b07;hb=11e39da6ccd4ff86be95de6af9e6f84ca67996d9;hp=4b607c1e6a36918c07d1957536c9c1da36dedd37;hpb=5881fa7229a25efd382668e6cd4a3af0f8d3198c;p=friendica.git diff --git a/src/Core/Console/DatabaseStructure.php b/src/Core/Console/DatabaseStructure.php index 4b607c1e6a..dededa9b3a 100644 --- a/src/Core/Console/DatabaseStructure.php +++ b/src/Core/Console/DatabaseStructure.php @@ -3,13 +3,11 @@ namespace Friendica\Core\Console; use Friendica\Core; +use Friendica\Core\Update; use Friendica\Database\DBA; use Friendica\Database\DBStructure; use RuntimeException; -require_once 'boot.php'; -require_once 'include/dba.php'; - /** * @brief Performs database updates from the command line * @@ -24,7 +22,7 @@ class DatabaseStructure extends \Asika\SimpleConsole\Console $help = << [-h|--help|-?] [-v] + bin/console dbstructure [-h|--help|-?] |-f|--force] [-v] Commands dryrun Show database update schema queries without running them @@ -33,16 +31,16 @@ Commands toinnodb Convert all tables from MyISAM to InnoDB Options - -h|--help|-? Show help information - -v Show more debug information. + -h|--help|-? Show help information + -v Show more debug information. + -f|--force Force the update command (Even if the database structure matches) + -o|--override Override running or stalling 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)); @@ -64,43 +62,20 @@ HELP; Core\Config::load(); + $a = get_app(); + switch ($this->getArgument(0)) { case "dryrun": - $output = DBStructure::update(true, false); + $output = DBStructure::update($a->getBasePath(), 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 = run_update_function($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 = run_update_function($x, 'update'); - if (!$r) { - break; - } - } - - Core\Config::set('system', 'build', DB_UPDATE_VERSION); + $force = $this->getOption(['f', 'force'], false); + $override = $this->getOption(['o', 'override'], false); + $output = Update::run($a->getBasePath(), $force, $override,true, false); break; case "dumpsql": ob_start(); - DBStructure::printStructure(); + DBStructure::printStructure($a->getBasePath()); $output = ob_get_clean(); break; case "toinnodb": @@ -108,11 +83,12 @@ HELP; DBStructure::convertToInnoDB(); $output = ob_get_clean(); break; + default: + $output = 'Unknown command: ' . $this->getArgument(0); } $this->out($output); return 0; } - }