Prisma setup with PostgreSQL and first migration #3

Closed
opened 2026-07-04 14:51:56 +02:00 by fable-5 · 0 comments
Collaborator

Context

All persistence goes through Prisma against PostgreSQL (ADR 0002/0006); migrations must run automatically on startup from day one.

Scope

Add Prisma to apps/api with schema.prisma containing only an instance_settings key-value model for now, a first migration, a PrismaService (Nest injectable), automatic prisma migrate deploy on API start, and a db service (pinned postgres image, volume, healthcheck) in the dev Compose overlay. Extend /readyz (new endpoint) to check DB connectivity and applied migrations.

Acceptance criteria

  • fresh docker compose up db + API start applies the migration automatically
  • /api/v1/readyz returns 503 when the DB is down, 200 when up
  • seed script pnpm --filter api db:seed runs (empty for now) and is wired for later fixtures

Technical notes

  • ADR 0002, ADR 0006. Pin the postgres major version.
  • Migration-on-start must be safe to run concurrently (advisory lock — Prisma handles this; verify).

Dependencies

Depends on #2.

Size: ~1 day


Conventions: English code/comments, clear human-readable code, no hard-coded UI strings (ADR 0012, add de and en), permission checks only via the shared guard (docs/architecture/permissions.md). Read the referenced ADRs before starting.

## Context All persistence goes through Prisma against PostgreSQL (ADR 0002/0006); migrations must run automatically on startup from day one. ## Scope Add Prisma to `apps/api` with `schema.prisma` containing only an `instance_settings` key-value model for now, a first migration, a `PrismaService` (Nest injectable), automatic `prisma migrate deploy` on API start, and a `db` service (pinned postgres image, volume, healthcheck) in the dev Compose overlay. Extend `/readyz` (new endpoint) to check DB connectivity and applied migrations. ## Acceptance criteria - [ ] fresh `docker compose up db` + API start applies the migration automatically - [ ] `/api/v1/readyz` returns 503 when the DB is down, 200 when up - [ ] seed script `pnpm --filter api db:seed` runs (empty for now) and is wired for later fixtures ## Technical notes - ADR 0002, ADR 0006. Pin the postgres major version. - Migration-on-start must be safe to run concurrently (advisory lock — Prisma handles this; verify). ## Dependencies Depends on #2. **Size**: ~1 day --- *Conventions: English code/comments, clear human-readable code, no hard-coded UI strings (ADR 0012, add `de` **and** `en`), permission checks only via the shared guard (docs/architecture/permissions.md). Read the referenced ADRs before starting.*
fable-5 added this to the M0 — Walking skeleton milestone 2026-07-04 14:51:56 +02:00
fable-5 added the
backend
label 2026-07-04 14:51:56 +02:00
Sign in to join this conversation.
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: stwaidele/dorfteich#3
No description provided.