Trying to re-apply already run migrations after loading a new databases dump runs into the problem that new tables created by the migrations linger, even if the tables loaded from the dump match the non-migrated state. Having lists of the tables matching the latest release available makes it easy to construct an sql command to dump the extra tables, so the migrations can be run. Adding generation and saving of a table list to bin/mkrelease.

- Legacy-Id: 13199
This commit is contained in:
Henrik Levkowetz 2017-04-12 18:16:19 +00:00
parent 823227ba23
commit 4c8f47ce73
2 changed files with 10 additions and 2 deletions

View file

@ -4,6 +4,7 @@ version=0.10
program=${0##*/}
progdir=${0%/*}
if [ "$progdir" = "$program" ]; then progdir="."; fi
PATH="$PATH:$progdir"
# ----------------------------------------------------------------------
function usage() {
@ -206,10 +207,17 @@ $do svn commit static/lib/ -m "Updated static files under static/lib/"
# [ $TCLOG -nt .svn/.latest-commit ] || die "Looked for ../test-crawl-*.log, but didn't find one newer than the latest repository commit ($RDATE)"
note "Upgrading the python library modules before checking migrations and running tests ..."
pip install --upgrade -r requirements.txt
$do pip install --upgrade -r requirements.txt
note "Checking that all model changes have been captured in migrations ..."
ietf/manage.py makemigrations | tee /dev/stderr | grep -q "^No changes detected$" || die "Model changes without migrations found."
$do ietf/manage.py makemigrations | tee /dev/stderr | grep -q "^No changes detected$" || die "Model changes without migrations found."
note "Making sure all migrations have been run ..."
$do ietf/manage.py migrate
note "Saving the current list of tables (for later use)"
$do ietf/manage.py dbshell <<< "show tables;" | tail -n +2 | jq -R -s "split(\"\n\") | {\"$VER\":.}" | jq -s 'add' - table-list.json | $do update table-list.json
$do svn commit table-list.json -m "List of tables at the time of release $VER"
note "Running the tests suite and writing release coverage data ..."
$do ietf/manage.py test --settings=ietf.settings_releasetest --save-version-coverage=$VER