From: Nicolas Boisselier Date: Thu, 7 Mar 2019 00:47:20 +0000 (+0000) Subject: lib/postgres/update.sh X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=fe77ab9d9019a16046921228975630f77e5d66ee;p=nb.git lib/postgres/update.sh --- diff --git a/lib/postgres/update.sh b/lib/postgres/update.sh new file mode 100755 index 00000000..391d861e --- /dev/null +++ b/lib/postgres/update.sh @@ -0,0 +1,11 @@ +#!/bin/sh +set -e +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 + +#. /etc/profile