mirror of
https://github.com/wallabag/docker.git
synced 2026-02-24 02:37:32 +01:00
Check if tables exist before installing
This works better than checking just the database, because it could be that an empty database has already been created (with e.g. Docker Compose). TABLES_EXIST should be empty if no tables, or will return a 1 for *each* table that exists.
This commit is contained in:
@ -76,6 +76,12 @@ provisioner() {
|
||||
echo "Configuring the Postgres database ..."
|
||||
psql -q -h "${SYMFONY__ENV__DATABASE_HOST}" -p "${SYMFONY__ENV__DATABASE_PORT}" -U "${POSTGRES_USER}" \
|
||||
-c "CREATE DATABASE ${SYMFONY__ENV__DATABASE_NAME};"
|
||||
fi
|
||||
|
||||
TABLES_EXIST="$(psql -qAt -h "${SYMFONY__ENV__DATABASE_HOST}" -p "${SYMFONY__ENV__DATABASE_PORT}" -U "${POSTGRES_USER}" \
|
||||
-c "SELECT 1 FROM pg_catalog.pg_tables WHERE schemaname = 'public';")"
|
||||
if [ "$TABLES_EXIST" == "" ]; then
|
||||
echo "Installing Wallabag ..."
|
||||
install_wallabag
|
||||
else
|
||||
echo "WARN: Postgres database is already configured. Remove the environment variable with root password."
|
||||
|
||||
Reference in New Issue
Block a user