Mercurial > gemma
changeset 4004:79adff625ed8
Let psql treat each schema update script as a file
No more semicolon required at the end of each script and
psql meta-commands such as \ir can be used, which is especially
useful to avoid duplicating DDL in update scripts.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 18 Jul 2019 19:46:19 +0200 |
parents | 5d4edf268aec |
children | 5c7e797347a3 |
files | schema/update-db.sh |
diffstat | 1 files changed, 3 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/schema/update-db.sh Thu Jul 18 18:14:03 2019 +0200 +++ b/schema/update-db.sh Thu Jul 18 19:46:19 2019 +0200 @@ -103,9 +103,9 @@ if [ -d "$d" ] && [ "$new_ver" -gt $current_ver ] ; then echo "Running updates for $new_ver ..." - sql=$( cat `echo "$d/"* | sort -n` ) - sql+="INSERT INTO gemma_schema_version(version) VALUES ($new_ver);" + psql -1qv ON_ERROR_STOP= -p "$port" -d "$db" \ + $(find "$d" -type f -printf ' -f %p') \ + -c "INSERT INTO gemma_schema_version(version) VALUES ($new_ver)" - psql -1 -q -p "$port" -d "$db" -c "$sql" fi done