feat(#194): 認可のセッションキー方式化に向けた DB スキーマ追加 - #212
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Visit the preview URL for this PR (updated for commit 35e67d5): https://tabi-share-8ef6b--pr212-feature-issue194-ses-trwlrn0a.web.app (expires Sat, 08 Aug 2026 02:40:45 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 9f2a87ede127df7673322845e34cf22c1372d720 |
| nullable=False, | ||
| comment="作成日時", | ||
| ) | ||
| last_seen_at: Mapped[datetime] = mapped_column( |
There was a problem hiding this comment.
usersテーブルにもlast_seen_atがあり、用途が不明
| """ | ||
|
|
||
| __tablename__ = "user_trip_access" | ||
|
|
There was a problem hiding this comment.
(任意)このテーブルにカラムが増えることが予想されるのであればサロゲートキーを用意してもよさそう
- User / UserSession / UserTripAccess モデルを追加 - Alembic migration で users / sessions / user_trip_access テーブルを作成 - docs/db_schema.md を全テーブル網羅で最新化
87ce807 to
35e67d5
Compare
|
@koki-fore レビューありがとうございます。以下の通り対応しました (fixup で 61a8abd に squash → force-push 済み、PR #210 側も rebase 済み): #2 (users.last_seen_at, line 342): 削除しました。 #3 (UserTripAccess サロゲートキー, line 394): 「任意」でしたが対応しました。
|
概要
issue #194 の認可方式移行 (PR #210) の前段として、認可用テーブルを追加する。
やったこと
users— 認可の主体。Cookie 発行時に匿名 user (firebase_uid IS NULL) を自動作成し、Firebase 認証時にfirebase_uidを埋めて昇格させるsessions— Cookie に載るsession_idとuser_idの紐付けuser_trip_access—(user_id, trip_id)複合 PK の中間表。並列付与の race をINSERT ... ON CONFLICT DO NOTHINGで idempotent 化する20260726_0000_add_users_sessions_and_user_trip_access_tables.py)docs/db_schema.mdを全面最新化(既存欠落テーブルLocation,DeviceSubscription,SentNotificationも含めて全体を追記)設計上の意思決定
users.emailは保持しない: Firebase Auth 側に一元化してプライバシー面積を最小化。Firebase Admin SDK で必要時にfirebase_uidから取得可能UserSession、テーブル名はsessions:sqlalchemy.orm.Sessionとの名前衝突を避けつつテーブル命名は業界慣習に沿うuser_trip_accessを複合 PK テーブルに: 単一 PK + UK ではなく(user_id, trip_id)の複合 PK にすることで、ON CONFLICT DO NOTHINGの効きが自然になるTest plan
pnpm dotenvx run -- sh -c 'cd server && uv run pytest'(既存テストを壊していないこと)関連