]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
docker: Further refine logic to apply migrations
authorStephen Finucane <stephen@that.guru>
Fri, 25 Mar 2022 11:57:33 +0000 (11:57 +0000)
committerStephen Finucane <stephen@that.guru>
Fri, 25 Mar 2022 11:59:13 +0000 (11:59 +0000)
We don't want to apply migrations by default since this will cause WIP
migrations to be applied if someone runs e.g. 'docker-compose run'. What
we really want to check is "are there any migrations currently applied?"
and skip if so, but Django doesn't provide an easy way to do this, so we
instead check for a random Django application.

Signed-off-by: Stephen Finucane <stephen@that.guru>
tools/docker/entrypoint.sh

index 02408e39ae81d01c131ddd263f4959c0334c22ed..c78c0581f1b52f8f892e0ddbbdda97716965bcbb 100755 (executable)
@@ -91,8 +91,11 @@ if ! test_database; then
     fi
 fi
 
-# load initial data
-if ! python manage.py migrate --check -v0; then
+# load initial data but only if we haven't loaded it before
+# HACK: We choose an arbitrary Django migration since we don't want to apply
+# Patchwork migrations by default each time since they might be WIP. The
+# 'sessions' migrations look unlikely to change very often.
+if ! python manage.py migrate sessions --check -v0; then
     python manage.py migrate #> /dev/null
     python manage.py loaddata default_tags #> /dev/null
     python manage.py loaddata default_states #> /dev/null