[open-ils-commits] r19838 - branches/rel_2_1/build/tools (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Mar 21 16:13:18 EDT 2011


Author: dbs
Date: 2011-03-21 16:13:13 -0400 (Mon, 21 Mar 2011)
New Revision: 19838

Modified:
   branches/rel_2_1/build/tools/update_db.sh
Log:
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.


Modified: branches/rel_2_1/build/tools/update_db.sh
===================================================================
--- branches/rel_2_1/build/tools/update_db.sh	2011-03-21 20:12:17 UTC (rev 19837)
+++ branches/rel_2_1/build/tools/update_db.sh	2011-03-21 20:13:13 UTC (rev 19838)
@@ -55,7 +55,8 @@
 
 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.



More information about the open-ils-commits mailing list