From 9bd2b3ab17a1bc56411cb496d5fd8685e924d453 Mon Sep 17 00:00:00 2001 From: Dale Hitchenor Date: Mon, 22 Jul 2024 06:53:25 +0000 Subject: Added util/update_db --- util/update_db | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 util/update_db diff --git a/util/update_db b/util/update_db new file mode 100644 index 000000000..0a4a04b28 --- /dev/null +++ b/util/update_db @@ -0,0 +1,54 @@ +#!/usr/bin/env php +' . PHP_EOL; + exit(1); +} + +require_once('include/cli_startup.php'); + +cli_startup(); + +use Zotlabs\Lib\Config; + +$CURRENT_DBV = Config::Get('system','db_version'); +$LATEST_DBV = DB_UPDATE_VERSION; + +if($argc == 1) { + if($CURRENT_DBV != $LATEST_DBV) { + echo "Updating database..."; + check_config(); + echo "Done"; + } else { + echo 'DB up to date: ' . $CURRENT_DBV . PHP_EOL; + } +} + +if($argc > 1 && $argv[1] === 'list') { + echo 'CURRENT: ' . $CURRENT_DBV . PHP_EOL; + $count = 1; + foreach (new DirectoryIterator('Zotlabs/Update') as $filename) { + if($filename->isDot()) continue; + $find = array("_",".php"); + $filename = str_replace($find,"",$filename); + if($filename > $CURRENT_DBV) { + echo $count . ': ' . $filename . PHP_EOL; + ++$count; + } + } + echo 'LATEST: ' . $LATEST_DBV . PHP_EOL; +} + +if($argc > 1 && $argv[1] === 'help' || $argv[1] === 'h') { + + echo <<<'EOHelp' +runs or lists db updates + +Usage: util/update_db + util/update_db list + util/update_db help + +EOHelp; + return; +} -- cgit v1.2.3