From c2b9eeac0689c5b44e41daa9b5318923614396e4 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 25 Jul 2014 09:49:48 +0200 Subject: [PATCH] [FIX] Allow higher hashrate values in statistcs table --- include/version.inc.php | 2 +- upgrade/definitions/0.0.13_to_0.0.14.inc.php | 30 ++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 upgrade/definitions/0.0.13_to_0.0.14.inc.php diff --git a/include/version.inc.php b/include/version.inc.php index 2b7ea18a..46e122fb 100644 --- a/include/version.inc.php +++ b/include/version.inc.php @@ -2,7 +2,7 @@ $defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1; define('MPOS_VERSION', '0.0.4'); -define('DB_VERSION', '0.0.13'); +define('DB_VERSION', '0.0.14'); define('CONFIG_VERSION', '0.0.8'); define('HASH_VERSION', 1); diff --git a/upgrade/definitions/0.0.13_to_0.0.14.inc.php b/upgrade/definitions/0.0.13_to_0.0.14.inc.php new file mode 100644 index 00000000..3db8f98d --- /dev/null +++ b/upgrade/definitions/0.0.13_to_0.0.14.inc.php @@ -0,0 +1,30 @@ +getValue('DB_VERSION'); // Our actual version installed + + // Upgrade specific variables + $aSql[] = "ALTER TABLE `statistics_users` CHANGE `hashrate` `hashrate` BIGINT UNSIGNED NOT NULL"; + $aSql[] = "UPDATE " . $setting->getTableName() . " SET value = '0.0.14' WHERE name = 'DB_VERSION'"; + + if ($db_version_now == $db_version_old && version_compare($db_version_now, DB_VERSION, '<')) { + // Run the upgrade + echo '- Starting database migration to version ' . $db_version_new . PHP_EOL; + foreach ($aSql as $sql) { + echo '- Preparing: ' . $sql . PHP_EOL; + $stmt = $mysqli->prepare($sql); + if ($stmt && $stmt->execute()) { + echo '- success' . PHP_EOL; + } else { + echo '- failed: ' . $mysqli->error . PHP_EOL; + exit(1); + } + } + } +} +?>