From: Stephen Finucane Date: Fri, 25 Mar 2022 11:57:33 +0000 (+0000) Subject: docker: Further refine logic to apply migrations X-Git-Tag: v3.1.0~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7186d2a6fe9d5cf976a7cf9029b465153d6ae126;p=thirdparty%2Fpatchwork.git docker: Further refine logic to apply migrations 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 --- diff --git a/tools/docker/entrypoint.sh b/tools/docker/entrypoint.sh index 02408e39..c78c0581 100755 --- a/tools/docker/entrypoint.sh +++ b/tools/docker/entrypoint.sh @@ -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