From: Hypolite Petovan Date: Sun, 21 Oct 2018 05:58:10 +0000 (-0400) Subject: Move DB_UPDATE_VERSION from boot.php to config/dbstructure.php X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=19ffc0510b71096442de0456c805543378dd42d6;p=friendica.git Move DB_UPDATE_VERSION from boot.php to config/dbstructure.php --- diff --git a/boot.php b/boot.php index a1154cf756..7fb87ca4eb 100644 --- a/boot.php +++ b/boot.php @@ -41,7 +41,6 @@ define('FRIENDICA_PLATFORM', 'Friendica'); define('FRIENDICA_CODENAME', 'The Tazmans Flax-lily'); define('FRIENDICA_VERSION', '2018.12-dev'); define('DFRN_PROTOCOL_VERSION', '2.23'); -define('DB_UPDATE_VERSION', 1289); define('NEW_UPDATE_ROUTINE_VERSION', 1170); /** diff --git a/config/dbstructure.php b/config/dbstructure.php index 7a96c0077f..96f90fb824 100644 --- a/config/dbstructure.php +++ b/config/dbstructure.php @@ -27,11 +27,16 @@ * ], * ], * + * If you need to make any change, make sure to increment the DB_UPDATE_VERSION constant value below. * */ use Friendica\Database\DBA; +if (!defined('DB_UPDATE_VERSION')) { + define('DB_UPDATE_VERSION', 1289); +} + return [ "addon" => [ "comment" => "registered addons", diff --git a/src/App.php b/src/App.php index d8d6439d72..6ec61db724 100644 --- a/src/App.php +++ b/src/App.php @@ -573,7 +573,11 @@ class App $stamp1 = microtime(true); - DBA::connect($db_host, $db_user, $db_pass, $db_data, $charset); + if (DBA::connect($db_host, $db_user, $db_pass, $db_data, $charset)) { + // Loads DB_UPDATE_VERSION constant + Database\DBStructure::definition(); + } + unset($db_host, $db_user, $db_pass, $db_data, $charset); $this->saveTimestamp($stamp1, 'network'); diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 4e4c69b1d8..f9335da8ed 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -5,8 +5,8 @@ namespace Friendica\Database; use Exception; -use Friendica\Core\Hook; use Friendica\Core\Config; +use Friendica\Core\Hook; use Friendica\Core\L10n; use Friendica\Util\DateTimeFormat; @@ -830,6 +830,7 @@ class DBStructure /** * Loads the database structure definition from the config/dbstructure.php file. + * On first pass, defines DB_UPDATE_VERSION constant. * * @see config/dbstructure.php * @return array diff --git a/update.php b/update.php index 0b5dfeef46..6a0ed1af20 100644 --- a/update.php +++ b/update.php @@ -32,7 +32,7 @@ require_once 'include/dba.php'; * * 1. Create a function "update_4712()" here in the update.php * 2. Apply the needed structural changes in config/dbStructure.php - * 3. Set DB_UPDATE_VERSION in boot.php to 4712. + * 3. Set DB_UPDATE_VERSION in config/dbstructure.php to 4712. * * If you need to run a script before the database update, name the function "pre_update_4712()" */