feat(server): schéma PostgreSQL sync-ready (ticket #49)

Ajoute la migration initiale (migrations/0001_initial_schema.sql,
incluant la table users nécessaire à l'adapter d'auth du ticket #48),
le runner de migration (bin/migrate.dart) et l'accès Postgres
(infrastructure/postgres/postgres_database.dart). dart pub get OK,
dart analyze clean, dart test vert (le test PostgreSQL réel est skip
faute de TEST_DATABASE_URL/Docker disponible dans ce sandbox ; SQL de
migration revu manuellement).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-19 10:05:24 +02:00
parent e06de40428
commit 79d994bdd7
8 changed files with 415 additions and 3 deletions

View File

@ -24,6 +24,39 @@ When `PORT` is not set, it listens on `8080`.
PORT=9090 dart run bin/server.dart
```
## PostgreSQL
Ticket #49 adds the initial sync-ready PostgreSQL schema and a minimal
connection/migration utility.
Database environment variables:
- `DATABASE_HOST`: PostgreSQL host.
- `DATABASE_PORT`: PostgreSQL port, defaults to `5432` when omitted.
- `DATABASE_NAME`: database name.
- `DATABASE_USER`: database user.
- `DATABASE_PASSWORD`: database password.
Apply migrations from `server/`:
```bash
DATABASE_HOST=localhost \
DATABASE_PORT=5432 \
DATABASE_NAME=gametime \
DATABASE_USER=gametime \
DATABASE_PASSWORD=gametime \
dart run bin/migrate.dart
```
Migrations are read from `server/migrations/` in alphabetical order. The v1
runner is intentionally simple; SQL files use idempotent DDL where practical.
The PostgreSQL integration test is skipped unless `TEST_DATABASE_URL` is set:
```bash
TEST_DATABASE_URL=postgres://gametime:gametime@localhost:5432/gametime dart test
```
Healthcheck:
```bash
@ -39,7 +72,8 @@ Expected response:
## Scope
Ticket #47 only scaffolds the Dart server, the hexagonal directory layout and
the `/health` endpoint.
the `/health` endpoint. Ticket #49 adds the first PostgreSQL schema only; auth,
sync endpoints and sharing behavior are still implemented in later tickets.
Upcoming tickets will fill the empty adapters and use cases: