From 724d8d3435658bfffba3eb10d8c0042470d7c62f Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 8 Jun 2020 19:11:53 +0200 Subject: [PATCH] run migrations when needed --- entrypoint.sh | 11 ++++++++++- worker-entrypoint.sh | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 6827d82..0172f0f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,7 +5,7 @@ cp -r storage.skel/* storage/ php /wait-for-db.php -if [[ ! -e storage/.docker.init ]]; +if [[ ! -e storage/.docker.init ]] then echo "Fresh installation, initializing database..." php artisan key:generate @@ -21,5 +21,14 @@ php artisan route:cache php artisan view:cache php artisan config:cache +echo "++++ Check for needed migrations... ++++" +# check for migrations +php artisan migrate:status | grep No && migrations=yes || migrations=no +if [ $migrations = "yes" ]; +then + php artisan migrate --force +fi + +echo "++++ Start apache... ++++" source /etc/apache2/envvars /usr/local/sbin/dumb-init apache2 -DFOREGROUND diff --git a/worker-entrypoint.sh b/worker-entrypoint.sh index a07ad0a..4fe941b 100755 --- a/worker-entrypoint.sh +++ b/worker-entrypoint.sh @@ -10,4 +10,12 @@ then exit 1 fi +gosu www-data php artisan migrate:status | grep No && migrations=yes || migrations=no +if [ $migrations = "yes" ]; +then + echo "Database needs migrations, exiting..." + sleep 5 + exit 1 +fi + gosu www-data php artisan horizon