Add the PostgreSQL Room and RaceSession schema
- Ngôn ngữ chính
- JavaScript
- Star
- 30
- Fork
- 9
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
Part of #199.
## Goal
Reshape the canonical Prisma/PostgreSQL model so rooms can own multiple independent race sessions without changing production read ownership yet.
## Schema direction
- Keep room identity, access, lifecycle, ownership, and optional competition association on `app.rooms`.
- Add `app.race_sessions` with room, event, format/mode, scramble source, state, scheduled times, and actual start/end times.
- Move current racing fields such as `cube_event`, `started`, and `next_solve_at` from their conceptual ownership on Room to RaceSession.
- Add session-level participant state for competing, waiting, and eligibility/registration where required by the domain contract.
- Make attempts reference `race_session_id`.
- Keep solves related through attempts; remove or deprecate redundant `room_id` only through an expand-and-contract migration.
- Preserve existing stable solve, attempt, room, and user identifiers.
- Add the minimal competition association defined by the domain contract.
## Migration requirements
- Use additive Prisma migrations first.
- Do not perform a destructive migration in application startup.
- Keep the currently deployed application compatible during the expansion phase.
- Add appropriate foreign keys, uniqueness constraints, and indexes for:
- active sessions by room;
- session attempt ordering;
- user solve history;
- competition-room session lookup;
- migration reconciliation.
- Define explicit delete/archive behavior. Historical solves must not cascade away because a room is hidden or archived.
## Acceptance criteria
- [ ] Prisma models and committed migrations represent the approved domain contract.
- [ ] Existing PostgreSQL data remains readable during rollout.
- [ ] A fresh PostgreSQL 17 database applies every migration with zero drift.
- [ ] Upgrade tests run from the current production schema.
- [ ] Foreign-key and uniqueness constraints reject invalid cross-room/session relationships.
- [ ] Indexes cover active room/session and history read paths.
- [ ] No migration deletes historical attempts or solves.
- [ ] Rollback compatibility and the later contract phase are documented.
## Dependencies
- The contract in #199 and its dedicated domain-contract issue must be settled first.
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với contract trong #199 và issue domain-contract riêng của nó, issue này phải được giải quyết trước khi thay đổi model chuẩn của Prisma/PostgreSQL. Xem lại schema production hiện tại, sau đó sử dụng các migration mang tính bổ sung của Prisma và các bài test upgrade; được xem là hoàn tất khi PostgreSQL 17 áp dụng mọi migration mà không có drift, bảo toàn dữ liệu lịch sử và đáp ứng các constraint và index được liệt kê.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- postgresql
- Lĩnh vực
- backend-api-design, databases
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100