]> git.nbdom.net Git - nb.git/commitdiff
lib/postgres/update.sh
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 7 Mar 2019 01:17:47 +0000 (01:17 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 7 Mar 2019 01:17:47 +0000 (01:17 +0000)
lib/postgres/update.sh

index a94bfb118be9908f59e564d8ecf055c8c5e341cf..d90c0446557db24181ee4861b77610eceb50ba33 100755 (executable)
@@ -5,5 +5,9 @@ cd "$(dirname "$0")"
 DB=${1:?Db name missing}
 
 psql "$DB" -Atc '\dt' | grep '^public|' | cut -d'|' -f2 | while read t; do
-       grep -vE '^DROP|--' $t.sql 2>/dev/null
-done | psql "$DB" -q
+
+       [ -r "$t.sql" ] || continue
+       echo "SELECT 'Update $t' as Comment;"
+       grep -vE '^DROP' "$t.sql"
+
+done | PGOPTIONS='--client-min-messages=warning' psql "$DB" -qAt