From 4c8f47ce73043362339161b3226d30d00347a0c2 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Wed, 12 Apr 2017 18:16:19 +0000 Subject: [PATCH] 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 --- bin/mkrelease | 12 ++++++++++-- {test => bin}/update | 0 2 files changed, 10 insertions(+), 2 deletions(-) rename {test => bin}/update (100%) diff --git a/bin/mkrelease b/bin/mkrelease index f288cb73a..66824b923 100755 --- a/bin/mkrelease +++ b/bin/mkrelease @@ -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 diff --git a/test/update b/bin/update similarity index 100% rename from test/update rename to bin/update