comparison schema/update-db.sh @ 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 074cf9349c71
children 6ee5523967ec
comparison
equal deleted inserted replaced
4003:5d4edf268aec 4004:79adff625ed8
101 for d in $BASEDIR/updates/* ; do 101 for d in $BASEDIR/updates/* ; do
102 new_ver=$( basename $d ) 102 new_ver=$( basename $d )
103 if [ -d "$d" ] && [ "$new_ver" -gt $current_ver ] ; then 103 if [ -d "$d" ] && [ "$new_ver" -gt $current_ver ] ; then
104 echo "Running updates for $new_ver ..." 104 echo "Running updates for $new_ver ..."
105 105
106 sql=$( cat `echo "$d/"* | sort -n` ) 106 psql -1qv ON_ERROR_STOP= -p "$port" -d "$db" \
107 sql+="INSERT INTO gemma_schema_version(version) VALUES ($new_ver);" 107 $(find "$d" -type f -printf ' -f %p') \
108 -c "INSERT INTO gemma_schema_version(version) VALUES ($new_ver)"
108 109
109 psql -1 -q -p "$port" -d "$db" -c "$sql"
110 fi 110 fi
111 done 111 done