diff --git a/include/version.inc.php b/include/version.inc.php index 2348930e..c9316aab 100644 --- a/include/version.inc.php +++ b/include/version.inc.php @@ -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.8'); +define('DB_VERSION', '0.0.9'); define('CONFIG_VERSION', '0.0.8'); // Fetch installed database version diff --git a/upgrade/definitions/0.0.8_to_0.0.9.inc.php b/upgrade/definitions/0.0.8_to_0.0.9.inc.php new file mode 100755 index 00000000..36de211a --- /dev/null +++ b/upgrade/definitions/0.0.8_to_0.0.9.inc.php @@ -0,0 +1,50 @@ +getValue('DB_VERSION'); // Our actual version installed + + // Upgrade specific variables + $aSql[] = "UPDATE " . $setting->getTableName() . " SET value = '0.0.9' WHERE name = 'DB_VERSION'"; + + echo '- Starting configuration migration into new location' . PHP_EOL; + $files = glob(BASEPATH . '../public/include/config/*'); + foreach ($files as $configFile) { + echo '- Moving ' . basename($configFile) . PHP_EOL; + system('mv ' . $configFile . ' ../include/config/'); + } + + echo '- Starting folder cleanup' . PHP_EOL; + $folders = array(BASEPATH . '../public/include/config', BASEPATH . '../public/include'); + foreach ($folders as $folderPath) { + if (file_exists($folderPath)) { + echo '- Removing ' . $folderPath . PHP_EOL; + $files = glob($folderPath . '/*'); + if (count($files) == 0) { + system('rmdir ' . $folderPath); + } else { + echo '! folder not empty, not removed' . PHP_EOL; + } + } + } + + 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); + } + } + } +} +?>