# HG changeset patch # User Søren Løvborg # Date 2016-07-13 19:39:14 # Node ID 51b1af58589bf975eacf187d6f613d210b3f1db5 # Parent 1a080d4e926e6f9d0862123a2e8fef261709875d db: script to test database upgrades dbmigrate-test executes Alembic upgrade scripts between two Kallithea versions in a clean environment. There is no automated testing of whether the upgraded database is functional, only that the upgrade proceeds without errors. diff --git a/scripts/dbmigrate-test b/scripts/dbmigrate-test new file mode 100755 --- /dev/null +++ b/scripts/dbmigrate-test @@ -0,0 +1,122 @@ +#!/bin/sh -e + +if [ $# -lt 2 ] || [ $# -gt 3 ]; then + cat >&2 <&1) + st=$? + if [ $st -ne 0 ]; then + echo "$output" >&2 + echo "Command $@ returned exit status $st." >&2 + exit 1 + fi +) + +HG() { + "${HG:-hg}" --repository "$source_repo" "$@" +} + +# If upgrading to "current revision", warn if working directory is dirty. +if [ ! "$to_rev" ] && [ "$(HG status -mard)" ]; then + announce "Warning: Uncommitted changes in working directory will be ignored!" +fi + +from_rev_hash=$(HG id --id --rev "${from_rev:-.}") +to_rev_hash=$(HG id --id --rev "${to_rev:-.}") +temp=$(readlink -f "$(mktemp --tmpdir -d 'dbmigrate-test.XXXXXX')") + +cat <