X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FCore%2FConsole%2FDatabaseStructure.php;h=13ed29b9df9872c22306b8890f56a4ccce0c6626;hb=214407bdc8e7ae126f1b44eaaa1f902e38fb1b9d;hp=eb4c6df99837dcf4bac1ded841b8b82ba179007f;hpb=88353ce56f0e5da6352af2d999a58bd0c9b375f7;p=friendica.git diff --git a/src/Core/Console/DatabaseStructure.php b/src/Core/Console/DatabaseStructure.php index eb4c6df998..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,12 +58,8 @@ HELP; throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments'); } - require_once '.htconfig.php'; - $result = \dba::connect($db_host, $db_user, $db_pass, $db_data); - unset($db_host, $db_user, $db_pass, $db_data); - - if (!$result) { - throw new \RuntimeException('Unable to connect to database'); + if (!DBA::connected()) { + throw new RuntimeException('Unable to connect to database'); } Core\Config::load(); @@ -71,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); @@ -82,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; }