run migrations when needed

This commit is contained in:
chris 2020-06-08 19:11:53 +02:00
parent e82d0a1ae6
commit 724d8d3435
2 changed files with 18 additions and 1 deletions

View File

@ -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

View File

@ -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