Skip to content

Commit ac6544f

Browse files
committed
feat: switch to PostgreSQL
BREAKING CHANGE: Adding a PostgreSQL container is required. A reseed of the database is also required, data cannot be transferred from sqlite3 to PostgreSQL. This reseed is done automatically on first start.
1 parent 434f05e commit ac6544f

31 files changed

Lines changed: 437 additions & 715 deletions

File tree

.env.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,14 @@ INTRA_API_UID=enter_your_uid_here
55
INTRA_API_SECRET=enter_your_secret_here
66
INTRA_CAMPUS_ID=14
77
INTRA_PISCINE_ASSISTANT_GROUP_ID=68
8+
9+
POSTGRES_USER=enter_a_postgres_user_here
10+
POSTGRES_PASSWORD=enter_a_postgres_password_here
11+
POSTGRES_DB=hero
12+
POSTGRES_HOST=localhost
13+
14+
# Below environment variable is used by Prisma to connect to the database
15+
# It should be in the format: postgresql://<POSTGRES_USER>:<POSTGRES_PASSWORD>@<POSTGRES_HOST>:5432/<POSTGRES_DB>
16+
# In DEVELOPMENT MODE when not using Docker to run the NodeJS code, POSTGRES_HOST should be "localhost",
17+
# while in PRODUCTION MODE, when Docker is used to run the NodeJS code, POSTGRES_HOST should be "codamhero-postgres" (the name of the postgres container in docker-compose.yml)
18+
PRISMA_DB_URL=postgresql://enter_a_postgres_user_here:enter_a_postgres_password_here@codamhero-postgres:5432/hero

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
build/*
33
dist/*
44
node_modules/*
5+
./database
56
*.db
67
*.db-journal
78
*/.DS_Store

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Only staff members or C.A.T.s have access to (parts of) piscine overviews by des
77
## Development
88
To get started, run the folllowing:
99
```bash
10+
docker compose up -d # for the PostgresQL database
1011
npm install
1112
npm run build
1213
cp .env.example .env

docker-compose.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
version: "3"
22
services:
3-
codamhero:
4-
build: .
3+
postgres:
4+
# container_name: codamhero-postgres
5+
image: "postgres:15"
6+
restart: unless-stopped
57
ports:
6-
- "4000:4000"
8+
- "5432:5432"
9+
env_file:
10+
- .env
711
volumes:
8-
- ./.env:/app/.env
9-
- ./hero.db:/app/hero.db
10-
environment:
11-
- NODE_ENV=development
12-
- DEV_DAYS_LIMIT=365
12+
- ./database:/var/lib/postgresql/data
13+
14+
# codamhero:
15+
# container_name: codamhero-web
16+
# build: .
17+
# ports:
18+
# - "4000:4000"
19+
# volumes:
20+
# - ./.env:/app/.env
21+
# environment:
22+
# - NODE_ENV=development
23+
# - DEV_DAYS_LIMIT=365

0 commit comments

Comments
 (0)