From a30535bd85da5fc627377009a69bf910504ef4e7 Mon Sep 17 00:00:00 2001 From: dbs Date: Mon, 21 Mar 2011 20:12:17 +0000 Subject: [PATCH] Enable update_db.sh to handle upgrading databases with release version When '0475' is mixed with '1.6.0.4', the latter wins as far as a plain MAX() operator goes. Ensuring that the version is all digits should help avoid the release version numbers in the config.upgrade_log table. Thanks to Thomas Berezansky for suggesting a SIMILAR TO operator variation that led to this approach. git-svn-id: svn://svn.open-ils.org/ILS/trunk@19837 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- build/tools/update_db.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/tools/update_db.sh b/build/tools/update_db.sh index 1d76bd7990..0aa07847e3 100755 --- a/build/tools/update_db.sh +++ b/build/tools/update_db.sh @@ -55,7 +55,8 @@ function feedback() { PSQL_ACCESS="-h $DB_HOST -U $DB_USER $DB_NAME"; -VERSION=$(psql -c "select max(version) from config.upgrade_log" -t $PSQL_ACCESS); +# 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."; # [ $VERBOSE ] && echo RAW VERSION: $VERSION # TODO: for verbose mode VERSION=$(echo $VERSION | sed -e 's/^ *0*//'); # This is a separate step so we can check $? above. -- 2.43.2