Skip to content

Commit c2b9eea

Browse files
committed
[FIX] Allow higher hashrate values in statistcs table
1 parent f58db4f commit c2b9eea

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

include/version.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
33

44
define('MPOS_VERSION', '0.0.4');
5-
define('DB_VERSION', '0.0.13');
5+
define('DB_VERSION', '0.0.14');
66
define('CONFIG_VERSION', '0.0.8');
77
define('HASH_VERSION', 1);
88

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
function run_0014() {
3+
// Ugly but haven't found a better way
4+
global $setting, $config, $user, $mysqli;
5+
6+
// Version information
7+
$db_version_old = '0.0.13'; // What version do we expect
8+
$db_version_new = '0.0.14'; // What is the new version we wish to upgrade to
9+
$db_version_now = $setting->getValue('DB_VERSION'); // Our actual version installed
10+
11+
// Upgrade specific variables
12+
$aSql[] = "ALTER TABLE `statistics_users` CHANGE `hashrate` `hashrate` BIGINT UNSIGNED NOT NULL";
13+
$aSql[] = "UPDATE " . $setting->getTableName() . " SET value = '0.0.14' WHERE name = 'DB_VERSION'";
14+
15+
if ($db_version_now == $db_version_old && version_compare($db_version_now, DB_VERSION, '<')) {
16+
// Run the upgrade
17+
echo '- Starting database migration to version ' . $db_version_new . PHP_EOL;
18+
foreach ($aSql as $sql) {
19+
echo '- Preparing: ' . $sql . PHP_EOL;
20+
$stmt = $mysqli->prepare($sql);
21+
if ($stmt && $stmt->execute()) {
22+
echo '- success' . PHP_EOL;
23+
} else {
24+
echo '- failed: ' . $mysqli->error . PHP_EOL;
25+
exit(1);
26+
}
27+
}
28+
}
29+
}
30+
?>

0 commit comments

Comments
 (0)