From 10ed91a20a1f76d452688b0033b8a33b7d988e32 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Tue, 27 Sep 2011 11:46:03 -0400 Subject: [PATCH] Teach update_db.sh to find the currently installed version number via eg_config and supply that when applying updates Signed-off-by: Mike Rylander Signed-off-by: Bill Erickson --- build/tools/update_db.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build/tools/update_db.sh b/build/tools/update_db.sh index e4130c26b6..3177f1b76f 100755 --- a/build/tools/update_db.sh +++ b/build/tools/update_db.sh @@ -55,6 +55,11 @@ function feedback() { PSQL_ACCESS="-h $DB_HOST -U $DB_USER $DB_NAME"; +# Find the current version of Evergreen, which is the installed version to which the upgrade script is being applied +EGVERSION=$(eg_config --version|cut -f2 -d' '); +[ $? -gt 0 ] && die "Could not find eg_config, please make sure it is in your path."; +[ -z "$EGVERSION" ] && die "Could not determine Evergreen version from eg_config."; + # Need to avoid versions like '1.6.0.4' from throwing off the upgrade VERSION=$(psql -c "SELECT MAX(version) FROM config.upgrade_log WHERE version ~ E'^\\\\d+$'" -t $PSQL_ACCESS); [ $? -gt 0 ] && die "Database access failed."; @@ -101,7 +106,7 @@ if [ $COUNT -gt 0 ] ; then for (( i=0; i<$COUNT; i++ )) ; do echo "* Applying ${FILES[$i]}" >&3; # to the main script STDOUT cat ${FILES[$i]}; # to the psql pipe - done | psql $PSQL_ACCESS ; + done | psql -set eg_version="'$EGVERSION'" $PSQL_ACCESS ; else echo "* Nothing to update"; fi -- 2.43.2