@@ -26,26 +26,37 @@ Prisma defines PostgreSQL in `server/prisma/schema.prisma`, using two schemas:
2626
2727| Schema | Contents |
2828| --- | --- |
29- | ` app ` | users, rooms, participants, attempts, and solves |
29+ | ` app ` | users, rooms, room/session participants, RaceSessions , attempts, and solves |
3030| ` analytics ` | pseudonymous metric events |
3131
3232PostgreSQL receives normalized copies of users/preferences, rooms and
33- participant state, attempts, durable solves, and sanitized analytics. OAuth
34- access tokens are deliberately not mirrored.
33+ participant state, normal-room RaceSession projections, attempts, durable
34+ solves, and sanitized analytics. OAuth access tokens are deliberately not
35+ mirrored. Existing PostgreSQL attempts and solves that predate the expansion
36+ remain unlinked until the backfill/reconciliation operation assigns them.
3537
36- Application reads do not use PostgreSQL yet. Setting ` POSTGRES_ENABLED=false `
37- disables initialization and mirrors. PostgreSQL failures are logged, while API
38- and Socket.IO health report the service as ` degraded ` instead of unavailable.
38+ Application reads remain MongoDB-backed except for the development-only solve
39+ history experiment. Setting ` POSTGRES_ENABLED=false ` disables initialization
40+ and mirrors. PostgreSQL failures are logged, while API and Socket.IO health
41+ report the service as ` degraded ` instead of unavailable.
3942
4043## Dual-Write Guarantees
4144
4245` server/postgres/dualWrite.js ` derives stable UUIDs from Mongo/WCA identifiers
4346and uses upserts so retries and future backfills remain idempotent.
4447
45- Room saves collect changed attempts/results and mirror only that delta. An
46- explicit event change replaces that room's PostgreSQL attempts so attempts
47- removed from MongoDB do not remain queryable. Complete snapshots are reserved
48- for explicit backfill behavior.
48+ Room saves collect changed attempts/results and mirror only that delta. A
49+ normal-room event change ends the current projected RaceSession and creates a
50+ new one, preserving the earlier session's attempts and solves. Complete
51+ snapshots are reserved for explicit backfill behavior.
52+
53+ ` GET /api/solve-history ` is a PostgreSQL-only, authenticated self-history
54+ endpoint enabled in development and optionally for selected production users
55+ through ` FEATURE_SOLVE_HISTORY_USER_IDS ` . It returns only session-linked solves
56+ for a current non-banned room participant; hidden, expired, and soft-deleted
57+ rooms remain readable to that participant. It never falls back to MongoDB or
58+ selects access codes, passwords, membership lists, moderation data, or email
59+ data.
4960
5061The mirror intentionally catches database failures and returns control to the
5162MongoDB-backed request. Monitoring must surface mirror errors because users may
0 commit comments