Skip to content

Commit 9c73e01

Browse files
committed
[MERGE] Merge conflict with development
2 parents 277c31a + c2b9eea commit 9c73e01

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
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)