Skip to content

Commit

Permalink
[update-docker-database] updating docker database in .env.example and…
Browse files Browse the repository at this point in the history
… also create database if not exists
  • Loading branch information
sarthaksavvy committed Oct 9, 2024
1 parent b13ea58 commit f2b0df6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
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

0 comments on commit f2b0df6

Please sign in to comment.