[TOOLS][DOCKER] Use a more robust way to check for database availability

This commit is contained in:
Hugo Sales 2022-03-19 15:49:04 +00:00
parent e22fe55bbe
commit 91fecd77ba
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
1 changed files with 3 additions and 3 deletions

View File

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