Skip to content

Commit 4c8f47c

Browse files
committed
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
1 parent 823227b commit 4c8f47c

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

bin/mkrelease

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ version=0.10
44
program=${0##*/}
55
progdir=${0%/*}
66
if [ "$progdir" = "$program" ]; then progdir="."; fi
7+
PATH="$PATH:$progdir"
78

89
# ----------------------------------------------------------------------
910
function usage() {
@@ -206,10 +207,17 @@ $do svn commit static/lib/ -m "Updated static files under static/lib/"
206207
# [ $TCLOG -nt .svn/.latest-commit ] || die "Looked for ../test-crawl-*.log, but didn't find one newer than the latest repository commit ($RDATE)"
207208

208209
note "Upgrading the python library modules before checking migrations and running tests ..."
209-
pip install --upgrade -r requirements.txt
210+
$do pip install --upgrade -r requirements.txt
210211

211212
note "Checking that all model changes have been captured in migrations ..."
212-
ietf/manage.py makemigrations | tee /dev/stderr | grep -q "^No changes detected$" || die "Model changes without migrations found."
213+
$do ietf/manage.py makemigrations | tee /dev/stderr | grep -q "^No changes detected$" || die "Model changes without migrations found."
214+
215+
note "Making sure all migrations have been run ..."
216+
$do ietf/manage.py migrate
217+
218+
note "Saving the current list of tables (for later use)"
219+
$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
220+
$do svn commit table-list.json -m "List of tables at the time of release $VER"
213221

214222
note "Running the tests suite and writing release coverage data ..."
215223
$do ietf/manage.py test --settings=ietf.settings_releasetest --save-version-coverage=$VER
File renamed without changes.

0 commit comments

Comments
 (0)