aboutsummaryrefslogtreecommitdiffstats
path: root/util/update_db
diff options
context:
space:
mode:
authorDale Hitchenor <dhitchenor@disroot.org>2024-07-22 06:53:25 +0000
committerMario <mario@mariovavti.com>2024-07-22 06:53:25 +0000
commit9bd2b3ab17a1bc56411cb496d5fd8685e924d453 (patch)
treea7f96e58803df2e99848927e70a09962026fd2d3 /util/update_db
parent7f292d47651902cf7077717e1c10e335f1f16fc2 (diff)
downloadvolse-hubzilla-9bd2b3ab17a1bc56411cb496d5fd8685e924d453.tar.gz
volse-hubzilla-9bd2b3ab17a1bc56411cb496d5fd8685e924d453.tar.bz2
volse-hubzilla-9bd2b3ab17a1bc56411cb496d5fd8685e924d453.zip
Added util/update_db
Diffstat (limited to 'util/update_db')
-rw-r--r--util/update_db54
1 files changed, 54 insertions, 0 deletions
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
+
+if(!file_exists('include/cli_startup.php')) {
+ echo 'Run update_db from the top level Hubzilla web directory, as util/update_db <args>' . 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;
+}