[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

View File

@ -2,8 +2,7 @@
case "${DBMS}" in case "${DBMS}" in
'postgres') 'postgres')
PGPASSWORD="${POSTGRES_PASSWORD}" psql -ltq -Upostgres -hdb | \ test "$(PGPASSWORD="${POSTGRES_PASSWORD}" psql -Upostgres -hdb -tAc "select 1 from pg_database where datname='${SOCIAL_DB}'")" = "1"
cut -d '|' -f1 | grep -Fwq "${SOCIAL_DB}"
DB_EXISTS=$? DB_EXISTS=$?
;; ;;
'mariadb') 'mariadb')
@ -28,7 +27,8 @@ if [ ${DB_EXISTS} -ne 0 ]; then
chmod g+w -R . chmod g+w -R .
chown -R :www-data . 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 doctrine:schema:create || exit 1
php bin/console app:populate_initial_values || exit 1 php bin/console app:populate_initial_values || exit 1