Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[update-docker-database] updating docker database in .env.example and also create database if not exists #49

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 7 additions & 2 deletions docker/psql/extensions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading