getValue('DB_VERSION'); // Our actual version installed // Upgrade specific variables $aSql[] = "CREATE TABLE `statistics_users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `account_id` int(11) NOT NULL, `hashrate` int(11) NOT NULL, `workers` int(11) NOT NULL, `sharerate` float NOT NULL, `timestamp` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `account_id_timestamp` (`account_id`,`timestamp`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8"; $aSql[] = "UPDATE " . $setting->getTableName() . " SET value = '0.0.13' 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); } } } } ?>