coder13 / coder13/LetsCube

Add the PostgreSQL Room and RaceSession schema

オープン
#203 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
area: data area: results enhancement priority: P1
主要言語
JavaScript
スター
30
フォーク
9
PR マージ指標
30日以内にマージされた PR はありません

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

#199 のコントラクトと、専用の domain-contract issue から始めてください。この issue は、正規の Prisma/PostgreSQL モデルを変更する前に解決されていなければなりません。現在の本番スキーマを確認し、その後、加算的な Prisma マイグレーションとアップグレードテストを使用してください。完了の条件は、PostgreSQL 17 がすべてのマイグレーションを drift なしで適用し、過去のデータを保持し、記載された制約とインデックスを満たすことです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
postgresql
領域
backend-api-design, databases
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。