diff --git a/.env.example b/.env.example index accef838..0cc80ed9 100644 --- a/.env.example +++ b/.env.example @@ -22,7 +22,7 @@ LOG_LEVEL=debug DB_CONNECTION=pgsql DB_HOST=127.0.0.1 DB_PORT=5432 -DB_DATABASE=laralamma +DB_DATABASE=larallama DB_USERNAME=postgres DB_PASSWORD=secret diff --git a/docker/psql/extensions.sh b/docker/psql/extensions.sh index 6b84440e..6fa38521 100644 --- a/docker/psql/extensions.sh +++ b/docker/psql/extensions.sh @@ -7,11 +7,16 @@ export PGUSER="$POSTGRES_USER" # Create the 'laralamma' template db "${psql[@]}" <<- 'EOSQL' -CREATE DATABASE laralamma IS_TEMPLATE true; +DO $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_database WHERE datname = 'larallama') THEN + CREATE DATABASE larallama IS_TEMPLATE true; + END IF; +END $$; EOSQL # Load PostGIS into both template_database and $POSTGRES_DB -for DB in laralamma "$POSTGRES_DB"; do +for DB in larallama "$POSTGRES_DB"; do echo "Loading PostGIS extensions into $DB" "${psql[@]}" --dbname="$DB" <<-'EOSQL' CREATE EXTENSION IF NOT EXISTS postgis;