#2539 - Fixed upgrading DB version

This commit is contained in:
Blonďák 2017-01-12 21:30:29 +01:00
parent 893d920327
commit 9f32f0119d
2 changed files with 4 additions and 3 deletions

View File

@ -2,7 +2,7 @@
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1; $defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
define('MPOS_VERSION', '1.0.6'); define('MPOS_VERSION', '1.0.6');
define('DB_VERSION', '1.0.1'); define('DB_VERSION', '1.0.2');
define('CONFIG_VERSION', '1.0.1'); define('CONFIG_VERSION', '1.0.1');
define('HASH_VERSION', 1); define('HASH_VERSION', 1);

View File

@ -1,7 +1,7 @@
<?php <?php
function run_102() { function run_102() {
// Ugly but haven't found a better way // Ugly but haven't found a better way
global $setting, $config, $coin_address, $user, $mysqli, $notification; global $setting, $config, $coin_address, $user, $mysqli;
// Version information // Version information
$db_version_old = '1.0.1'; // What version do we expect $db_version_old = '1.0.1'; // What version do we expect
@ -17,7 +17,8 @@ function run_102() {
PRIMARY KEY (`account_id`,`name`) PRIMARY KEY (`account_id`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
"; ";
$aSql[] = "UPDATE " . $setting->getTableName() . " SET value = '".$db_version_new."' WHERE name = 'DB_VERSION'";
if ($db_version_now == $db_version_old && version_compare($db_version_now, DB_VERSION, '<')) { if ($db_version_now == $db_version_old && version_compare($db_version_now, DB_VERSION, '<')) {
// Run the upgrade // Run the upgrade
echo '- Starting database migration to version ' . $db_version_new . PHP_EOL; echo '- Starting database migration to version ' . $db_version_new . PHP_EOL;