feat: Try to create empty database at startup, in order to avoid the error message : "The database is not up or not reachable" if database doesnt exist. (#119)

This commit is contained in:
Guillaume Ponty 2021-03-25 17:20:06 +01:00 committed by GitHub
parent 4bc3a1a452
commit cb77bd16f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,6 +30,8 @@ if [ "$1" = 'php-fpm' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then
fi
if grep -q ^DATABASE_URL= .env; then
echo "Try to create database"
bin/console doctrine:database:create --if-not-exists --no-interaction
echo "Waiting for db to be ready..."
ATTEMPTS_LEFT_TO_REACH_DATABASE=60
until [ $ATTEMPTS_LEFT_TO_REACH_DATABASE -eq 0 ] || DATABASE_ERROR=$(bin/console doctrine:query:sql "SELECT 1" 2>&1); do