File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 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+ ?>
You can’t perform that action at this time.
0 commit comments