Skip to content

Commit defd3d4

Browse files
committed
fix(init): Initialzer has to fail if migration is not done
Signed-off-by: kiblik <5609770+kiblik@users.noreply.github.com>
1 parent ffc03a9 commit defd3d4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

docker/entrypoint-initializer.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ set -e # needed to handle "exit" correctly
55
. /secret-file-loader.sh
66
. /reach_database.sh
77

8+
returncode=0
9+
810
initialize_data()
911
{
1012
# Test types shall be initialized every time by the initializer, to make sure test types are complete
@@ -59,7 +61,7 @@ umask 0002
5961
if [ "${DD_INITIALIZE}" = false ]
6062
then
6163
echo "Echo initialization skipped. Exiting."
62-
exit
64+
exit $returncode
6365
fi
6466
echo "Initializing."
6567

@@ -102,7 +104,8 @@ EOD
102104
then
103105
echo "You have set 'enable_auditlog' to False in the past. It is not possible to manage auditlog in System settings anymore. If you would like to keep auditlog disabled, you need to set environmental variable DD_ENABLE_AUDITLOG to False for all Django containers (uwsgi, celeryworker & initializer)."
104106
echo "Or there is some other error in checking script. Check logs of this container."
105-
exit 47
107+
returncode=47
108+
exit $returncode
106109
fi
107110

108111

@@ -129,6 +132,7 @@ docker compose exec uwsgi bash -c 'python manage.py makemigrations -v2'
129132
130133
EOF
131134
echo "WARNING: Continuing startup despite missing migrations..."
135+
returncode=52
132136
}
133137

134138
echo "Migrating"
@@ -150,7 +154,7 @@ then
150154
echo "$ docker compose exec uwsgi /bin/bash -c 'python manage.py createsuperuser'"
151155
create_announcement_banner
152156
initialize_data
153-
exit
157+
exit $returncode
154158
fi
155159

156160
if [ -z "${DD_ADMIN_PASSWORD}" ]
@@ -175,3 +179,5 @@ then
175179
create_announcement_banner
176180
initialize_data
177181
fi
182+
183+
exit $returncode

0 commit comments

Comments
 (0)