From 7186d2a6fe9d5cf976a7cf9029b465153d6ae126 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 25 Mar 2022 11:57:33 +0000 Subject: [PATCH] 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 --- tools/docker/entrypoint.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 -- 2.47.3