[UPDATE] Shares to bigint for blocks table (#2382), SQL file cleanup

This commit is contained in:
Sebastian Grewe 2015-01-18 15:40:57 +01:00
parent 943dcd03b7
commit e0f10c046e
13 changed files with 30 additions and 24 deletions

View File

@ -46,7 +46,7 @@ CREATE TABLE IF NOT EXISTS `blocks` (
`accounted` tinyint(1) NOT NULL DEFAULT '0',
`account_id` int(255) unsigned DEFAULT NULL,
`worker_name` varchar(50) DEFAULT 'unknown',
`shares` int(255) unsigned DEFAULT NULL,
`shares` bigint(30) unsigned DEFAULT NULL,
`share_id` bigint(30) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `height` (`height`,`blockhash`),

View File

@ -1,2 +0,0 @@
ALTER TABLE `statistics_shares` ADD `pplns_valid` int(11) NOT NULL AFTER `invalid` ;
ALTER TABLE `statistics_shares` ADD `pplns_invalid` int(11) NOT NULL DEFAULT 0 AFTER `pplns_valid` ;

View File

@ -1 +0,0 @@
ALTER TABLE `settings` CHANGE `value` `value` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ;

View File

@ -1 +0,0 @@
ALTER TABLE `monitoring` CHANGE `value` `value` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ;

View File

@ -1 +0,0 @@
ALTER TABLE `blocks` ADD `worker_name` varchar(50) DEFAULT 'unknown' AFTER `account_id`;

View File

@ -1,7 +0,0 @@
CREATE TABLE `templates` (
`template` varchar(255) NOT NULL,
`active` tinyint(1) NOT NULL DEFAULT 0,
`content` mediumtext,
`modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`template`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -1 +0,0 @@
ALTER TABLE `transactions` ADD `txid` VARCHAR( 256 ) NULL DEFAULT NULL AFTER `timestamp` ;

View File

@ -1 +0,0 @@
ALTER TABLE `accounts` ADD `failed_pins` INT NOT NULL AFTER `failed_logins` ;

View File

@ -1,4 +0,0 @@
ALTER TABLE `shares_archive` ADD INDEX ( `username` ) ;
ALTER TABLE `shares_archive` ADD INDEX ( `share_id` ) ;
ALTER TABLE `shares_archive` ADD INDEX ( `our_result` ) ;
ALTER TABLE `shares_archive` ADD INDEX ( `time` ) ;

View File

@ -1,2 +0,0 @@
ALTER TABLE `token_types` ADD `expiration` INT NULL DEFAULT '0';
UPDATE `token_types` SET `expiration` = 3600 WHERE `id` = 1;

View File

@ -1 +0,0 @@
INSERT INTO `token_types` (`name`, `expiration`) VALUES ('account_unlock', 0);

View File

@ -1,2 +0,0 @@
INSERT INTO `settings` (`name`, `value`) VALUES ('DB_VERSION', '0.0.1') ON DUPLICATE KEY UPDATE `value` = '0.0.1';
INSERT INTO `settings` (`name`, `value`) VALUES ('db_upgrade_required', 0) ON DUPLICATE KEY UPDATE `value` = 0;

View File

@ -0,0 +1,29 @@
<?php
function run_100() {
// Ugly but haven't found a better way
global $setting, $config, $statistics, $block, $mysqli;
// Version information
$db_version_old = '0.0.15'; // What version do we expect
$db_version_new = '1.0.0'; // 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[] = "ALTER TABLE `blocks` CHANGE `shares` `shares` BIGINT(30) unsigned NOT NULL AUTO_INCREMENT";
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);
}
}
}
}
?>