From 91fecd77bac86e6759c688bcf16d4b76a9c7d70a Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Sat, 19 Mar 2022 15:49:04 +0000 Subject: [PATCH] [TOOLS][DOCKER] Use a more robust way to check for database availability --- docker/social/install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/social/install.sh b/docker/social/install.sh index 368315129d..df967964ae 100755 --- a/docker/social/install.sh +++ b/docker/social/install.sh @@ -2,8 +2,7 @@ case "${DBMS}" in 'postgres') - PGPASSWORD="${POSTGRES_PASSWORD}" psql -ltq -Upostgres -hdb | \ - cut -d '|' -f1 | grep -Fwq "${SOCIAL_DB}" + test "$(PGPASSWORD="${POSTGRES_PASSWORD}" psql -Upostgres -hdb -tAc "select 1 from pg_database where datname='${SOCIAL_DB}'")" = "1" DB_EXISTS=$? ;; 'mariadb') @@ -28,7 +27,8 @@ if [ ${DB_EXISTS} -ne 0 ]; then chmod g+w -R . chown -R :www-data . - php bin/console doctrine:database:create || exit 1 + php bin/console doctrine:database:drop -f + php bin/console doctrine:database:create php bin/console doctrine:schema:create || exit 1 php bin/console app:populate_initial_values || exit 1