Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f2b0df6

Browse files
committedOct 9, 2024·
[update-docker-database] updating docker database in .env.example and also create database if not exists
1 parent b13ea58 commit f2b0df6

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed
 

‎.env.example

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ LOG_LEVEL=debug
2222
DB_CONNECTION=pgsql
2323
DB_HOST=127.0.0.1
2424
DB_PORT=5432
25-
DB_DATABASE=laralamma
25+
DB_DATABASE=larallama
2626
DB_USERNAME=postgres
2727
DB_PASSWORD=secret
2828

‎docker/psql/extensions.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@ export PGUSER="$POSTGRES_USER"
77

88
# Create the 'laralamma' template db
99
"${psql[@]}" <<- 'EOSQL'
10-
CREATE DATABASE laralamma IS_TEMPLATE true;
10+
DO $$
11+
BEGIN
12+
IF NOT EXISTS (SELECT 1 FROM pg_database WHERE datname = 'larallama') THEN
13+
CREATE DATABASE larallama IS_TEMPLATE true;
14+
END IF;
15+
END $$;
1116
EOSQL
1217

1318
# Load PostGIS into both template_database and $POSTGRES_DB
14-
for DB in laralamma "$POSTGRES_DB"; do
19+
for DB in larallama "$POSTGRES_DB"; do
1520
echo "Loading PostGIS extensions into $DB"
1621
"${psql[@]}" --dbname="$DB" <<-'EOSQL'
1722
CREATE EXTENSION IF NOT EXISTS postgis;

0 commit comments

Comments
 (0)
Please sign in to comment.