Skip to content
Merged
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: 0 additions & 2 deletions database/install.sql

This file was deleted.

15 changes: 15 additions & 0 deletions database/seeds/001-install.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'marcus') THEN
CREATE ROLE marcus LOGIN PASSWORD 'marcus';
END IF;
END
$$;

DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_database WHERE datname = 'application') THEN
CREATE DATABASE application OWNER marcus;
END IF;
END
$$;
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions database/setup.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
psql -f install.sql -U postgres
PGPASSWORD=marcus psql -d application -f structure.sql -U marcus
PGPASSWORD=marcus psql -d application -f data.sql -U marcus
psql -f ./seeds/001-install.sql -U postgres
PGPASSWORD=marcus psql -d application -f ./seeds/002-structure.sql -U marcus
PGPASSWORD=marcus psql -d application -f ./seeds/003-data.sql -U marcus
9 changes: 7 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ services:
- DB_HOST=pg-example
- REDIS_HOST=redis-example
depends_on:
- pg-example
- redis-example
pg-example:
condition: service_healthy
redis-example:
condition: service_started
ports:
- "127.0.0.1:8000:8000"
- "127.0.0.1:8001:8001"
Expand All @@ -25,8 +27,11 @@ services:
- POSTGRES_DB=application
volumes:
- postgres_data:/var/lib/postgresql/data
- ./database/seeds:/docker-entrypoint-initdb.d:ro
ports:
- "127.0.0.1:5432:5432"
healthcheck:
test: ["CMD", "pg_isready", "-U", "marcus"]
restart: always

redis-example:
Expand Down