#!/bin/sh
#
SQLITE=/usr/bin/sqlite3
cp /var/db.dat /tmp/db.dat.down
echo "checking database revision."
db=`$SQLITE /tmp/db.dat.down "select value from options where name = 'schema_revision'"`
echo initial version $db
$SQLITE /tmp/db.dat.down < /var/bin/downgrade_db_from_${db}_to_R7327.sql
mv /tmp/db.dat.down /tmp/db.dat
db=`$SQLITE /tmp/db.dat "select value from options where name = 'schema_revision'"`
echo target version $db
echo saved as /tmp/db.dat
