X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FConsole%2FDatabaseStructure.php;h=13ed29b9df9872c22306b8890f56a4ccce0c6626;hb=214407bdc8e7ae126f1b44eaaa1f902e38fb1b9d;hp=11904843102a64aa4e34fd9d6031c1c922c37beb;hpb=66a103e36a42ab251fd9ca6c4b56b54380e4d535;p=friendica.git diff --git a/src/Core/Console/DatabaseStructure.php b/src/Core/Console/DatabaseStructure.php index 1190484310..13ed29b9df 100644 --- a/src/Core/Console/DatabaseStructure.php +++ b/src/Core/Console/DatabaseStructure.php @@ -3,13 +3,15 @@ namespace Friendica\Core\Console; use Friendica\Core; +use Friendica\Database\DBA; use Friendica\Database\DBStructure; +use RuntimeException; require_once 'boot.php'; require_once 'include/dba.php'; /** - * @brief Does database updates from the command line + * @brief Performs database updates from the command line * * @author Hypolite Petovan */ @@ -20,7 +22,7 @@ class DatabaseStructure extends \Asika\SimpleConsole\Console protected function getHelp() { $help = << [-h|--help|-?] [-v] @@ -56,8 +58,8 @@ HELP; throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments'); } - if (!\dba::connected()) { - throw new \RuntimeException('Unable to connect to database'); + if (!DBA::connected()) { + throw new RuntimeException('Unable to connect to database'); } Core\Config::load(); @@ -67,8 +69,6 @@ HELP; $output = DBStructure::update(true, false); break; case "update": - $output = DBStructure::update(true, true); - $build = Core\Config::get('system', 'build'); if (empty($build)) { Core\Config::set('system', 'build', DB_UPDATE_VERSION); @@ -78,9 +78,19 @@ HELP; $stored = intval($build); $current = intval(DB_UPDATE_VERSION); - // run any left update_nnnn functions in update.php + // 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); + $r = run_update_function($x, 'update'); if (!$r) { break; }