[ADDED] SQL Upgrade Script
This commit is contained in:
parent
67a4713cf0
commit
1f6ef81b9c
@ -2,7 +2,7 @@
|
||||
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
|
||||
|
||||
define('MPOS_VERSION', '0.0.4');
|
||||
define('DB_VERSION', '0.0.7');
|
||||
define('DB_VERSION', '0.0.8');
|
||||
define('CONFIG_VERSION', '0.0.7');
|
||||
|
||||
// Fetch installed database version
|
||||
|
||||
36
upgrade/db_version_0.0.8.php
Executable file
36
upgrade/db_version_0.0.8.php
Executable file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
/* Upgarde script for https://github.com/MPOS/php-mpos/issues/1981 */
|
||||
|
||||
// Change to working directory
|
||||
chdir(dirname(__FILE__));
|
||||
|
||||
// Include all settings and classes
|
||||
require_once('shared.inc.php');
|
||||
|
||||
// Version information
|
||||
$db_version_old = '0.0.7'; // What version do we expect
|
||||
$db_version_new = '0.0.8'; // What is the new version we wish to upgrade to
|
||||
$db_version_now = $setting->getValue('DB_VERSION'); // Our actual version installed
|
||||
|
||||
// Upgrade specific variables
|
||||
$dDifficulty = POW(2, ($config['difficulty'] - 16));
|
||||
$aSql[] = "UPDATE " . $statistics->getTableName() . " SET valid = valid * $dDifficulty, invalid = invalid * $dDifficulty, pplns_valid = pplns_valid * $dDifficulty, pplns_invalid = pplns_invalid * $dDifficulty";
|
||||
$aSql[] = "UPDATE " . $block->getTableName() . " SET shares = shares * $dDifficulty";
|
||||
$aSql[] = "UPDATE " . $setting->getTableName() . " SET value = '0.0.8' 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
51
upgrade/shared.inc.php
Normal file
51
upgrade/shared.inc.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Copyright:: 2013, Sebastian Grewe
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
// MODIFY THIS
|
||||
// We need to find our include files so set this properly
|
||||
define("BASEPATH", "../public/");
|
||||
|
||||
/*****************************************************
|
||||
* No need to change beyond this point *
|
||||
*****************************************************/
|
||||
|
||||
define('SECURITY', '*)WT#&YHfd');
|
||||
// Whether or not to check SECHASH for validity, still checks if SECURITY defined as before if disabled
|
||||
define('SECHASH_CHECK', false);
|
||||
|
||||
// change SECHASH every second, we allow up to 3 sec back for slow servers
|
||||
if (SECHASH_CHECK) {
|
||||
function fip($tr=0) { return md5(SECURITY.(time()-$tr).SECURITY); }
|
||||
define('SECHASH', fip());
|
||||
function cfip() { return (fip()==SECHASH||fip(1)==SECHASH||fip(2)==SECHASH) ? 1 : 0; }
|
||||
} else {
|
||||
function cfip() { return (@defined('SECURITY')) ? 1 : 0; }
|
||||
}
|
||||
|
||||
// Include our configuration (holding defines for the requires)
|
||||
require_once(BASEPATH . 'include/config/global.inc.dist.php');
|
||||
require_once(BASEPATH . 'include/config/global.inc.php');
|
||||
|
||||
require_once(BASEPATH . 'include/config/security.inc.dist.php');
|
||||
@include_once(BASEPATH . 'include/config/security.inc.php');
|
||||
|
||||
require_once(BASEPATH . 'include/bootstrap.php');
|
||||
require_once(BASEPATH . 'include/version.inc.php');
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user