Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/version.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;

define('MPOS_VERSION', '1.0.9');
define('DB_VERSION', '1.0.2');
define('DB_VERSION', '1.0.3');
define('CONFIG_VERSION', '1.0.1');
define('HASH_VERSION', 1);

Expand Down
6 changes: 3 additions & 3 deletions sql/000_base_structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ CREATE TABLE IF NOT EXISTS `settings` (
UNIQUE KEY `setting` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `settings` (`name`, `value`) VALUES ('DB_VERSION', '1.0.2');
INSERT INTO `settings` (`name`, `value`) VALUES ('DB_VERSION', '1.0.3');

CREATE TABLE IF NOT EXISTS `shares` (
`id` bigint(30) NOT NULL AUTO_INCREMENT,
Expand Down Expand Up @@ -182,9 +182,9 @@ CREATE TABLE IF NOT EXISTS `statistics_shares` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`account_id` int(10) unsigned NOT NULL,
`block_id` int(10) unsigned NOT NULL,
`valid` bigint(20) NOT NULL,
`valid` bigint(20) NOT NULL DEFAULT '0',
`invalid` bigint(20) NOT NULL DEFAULT '0',
`pplns_valid` bigint(20) NOT NULL,
`pplns_valid` bigint(20) NOT NULL DEFAULT '0',
`pplns_invalid` bigint(20) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `account_id` (`account_id`),
Expand Down
32 changes: 32 additions & 0 deletions upgrade/definitions/1.0.2_to_1.0.3.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
function run_103() {
// Ugly but haven't found a better way
global $setting, $config, $coin_address, $user, $mysqli;

// Version information
$db_version_old = '1.0.2'; // What version do we expect
$db_version_new = '1.0.3'; // What is the new version we wish to upgrade to
$db_version_now = $setting->getValue('DB_VERSION'); // Our actual version installed

// Upgrade specific variables
$aSql[] = "UPDATE `statistics_shares` SET `valid` = '0' WHERE `valid` IS NULL;";
$aSql[] = "UPDATE `statistics_shares` SET `pplns_valid` = '0' WHERE `pplns_valid` IS NULL;";
$aSql[] = "ALTER TABLE `statistics_shares` CHANGE `valid` `valid` BIGINT(20) NOT NULL DEFAULT '0', CHANGE `pplns_valid` `pplns_valid` BIGINT(20) NOT NULL DEFAULT '0';";
$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, '<')) {
// 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);
}
}
}
}
?>