全 93 テーブルのうち、モバイルが読み書きするのはこの 12 テーブル。 Of the 93 tables total, these 12 are what the mobile app reads or writes.
Parky のデータベース(Supabase PostgreSQL)には 93 テーブルありますが、 モバイルアプリから見える/触れるのはこのページにまとめた少数のテーブルだけです。 残りは管理者ポータル・マーケティングポータル・内部処理のためのものです。
The Parky database (Supabase PostgreSQL) has 93 tables, but only a small set is visible to the mobile app. Everything else is for the admin portal, marketing portal, or internal workflows.
大前提:モバイルは BFF 経由でしか触らない Premise: mobile never touches these tables directly
/v1/*)経由です。
本ページは「BFF のレスポンスに含まれるフィールドはどのテーブル由来か」を理解するための参考です。
RLS ポリシーは BFF の service_role コンテキストで評価されるので、クライアントからの個別 RLS 検証は必要ありません。
The mobile app never hits Supabase DB directly. Every read and write goes through the Parky BFF (/v1/*).
This page is a reference for understanding where each BFF response field comes from.
RLS is evaluated in the BFF's service-role context, so client-side RLS checks are not needed.
モバイルが関わる 12 テーブルの関係図 The 12 mobile-facing tables
erDiagram
APP_USERS ||--o{ PARKING_SESSIONS : "starts"
APP_USERS ||--o{ USER_SAVED_PARKING_LOTS : "favorites"
APP_USERS ||--o{ USER_VEHICLES : "owns"
APP_USERS ||--o{ USER_PUSH_TOKENS : "devices"
APP_USERS ||--o{ USER_NOTIFICATIONS : "receives"
APP_USERS ||--o| USER_SUBSCRIPTIONS : "has"
APP_USERS ||--o{ USER_SEARCH_PRESETS : "saves"
APP_USERS ||--o{ USER_EXP : "earns"
APP_USERS ||--o{ USER_BADGES : "earns"
APP_USERS ||--o{ REVIEWS : "posts"
PARKING_LOTS ||--o{ PARKING_SESSIONS : "hosts"
PARKING_LOTS ||--o{ REVIEWS : "receives"
PARKING_LOTS ||--o{ USER_SAVED_PARKING_LOTS : "saved by"
APP_USERS {
uuid id PK
uuid auth_user_id FK
string display_name
string email
code user_status
code vehicle_type
bool premium
timestamp deleted_at
}
PARKING_LOTS {
uuid id PK
string name
point location
jsonb pricing_rules
jsonb tags
code status
}
PARKING_SESSIONS {
uuid id PK
uuid user_id FK
uuid parking_lot_id FK
timestamp entry_at
timestamp exit_at
code session_status
int fee_amount
}
USER_SAVED_PARKING_LOTS {
uuid user_id FK
uuid parking_lot_id FK
}
USER_VEHICLES {
uuid id PK
uuid user_id FK
code vehicle_type
string plate
timestamp deleted_at
}
USER_PUSH_TOKENS {
uuid id PK
uuid user_id FK
string token
code device_type
string app_version
}
USER_NOTIFICATIONS {
uuid id PK
uuid user_id FK
code notif_type
code notif_status
timestamp read_at
}
USER_SUBSCRIPTIONS {
uuid id PK
uuid user_id FK
code platform
string product_id
timestamp expires_at
}
USER_SEARCH_PRESETS {
uuid id PK
uuid user_id FK
jsonb filters
bool is_default
}
USER_EXP {
uuid user_id FK
int total_exp
int level
}
USER_BADGES {
uuid user_id FK
string badge_code
timestamp earned_at
}
REVIEWS {
uuid id PK
uuid user_id FK
uuid parking_lot_id FK
int rating
text comment
code review_status
}
テーブル詳細 Table details
1. app_users
- 役割:Parky のエンドユーザー。
auth.users(Supabase Auth)とauth_user_idで 1:1 連携 - Role: End users of Parky, linked 1:1 to
auth.users(Supabase Auth) viaauth_user_id - モバイルの操作:
GET /v1/me(自分の情報取得)/PATCH /v1/me(更新)/POST /v1/me/withdraw(退会) - Mobile ops:
GET /v1/me/PATCH /v1/me/POST /v1/me/withdraw - 重要フィールド:
user_status(コード値)、vehicle_type(コード値)、premium(サブスク判定)、deleted_at(ソフトデリート) - Key fields:
user_status(code),vehicle_type(code),premium,deleted_at(soft delete)
2. parking_lots (読み取り専用)
- 役割:駐車場マスター。検索・詳細表示の中心
- Role: Parking-lot master — the heart of search and detail screens
- モバイルの操作:
GET /v1/parking-lots、GET /v1/parking-lots/nearby、GET /v1/parking-lots/{id}、POST /v1/parking-lots/{id}/calc-fee - Mobile ops:
GET /v1/parking-lots,GET /v1/parking-lots/nearby,GET /v1/parking-lots/{id},POST /v1/parking-lots/{id}/calc-fee - 注意:モバイルからは書き込み不可。登録・編集はオーナーポータル経由
- Note: Mobile cannot write. Creation / edits happen in the owner portal
3. parking_sessions
- 役割:駐車セッション。駐車開始〜終了までのライフサイクルを保持
- Role: Parking session lifecycle, from start to finalize
- モバイルの操作:
POST /v1/parking-sessions(開始)/POST /v1/parking-sessions/{id}/finalize(終了)/POST .../cancel(5 分以内)/GET /v1/me/parking-sessions(履歴) - Mobile ops:
POST /v1/parking-sessions(start),POST .../finalize,POST .../cancel(within 5 min),GET /v1/me/parking-sessions(history) - 状態遷移:
active→finalized/active→cancelled(5 分以内)/ 70h でauto_end_soon通知、72h で自動終了 - States:
active→finalized/active→cancelled(within 5 min) /auto_end_soonpush at 70h, auto-finalized at 72h
4. user_saved_parking_lots
- 役割:お気に入り駐車場(リンクテーブル)
- Role: Favorites (link table)
- モバイルの操作:
GET /v1/me/saved-parking-lots/POST/DELETE /v1/me/saved-parking-lots/{lotId} - Mobile ops:
GET/POST/DELETE /v1/me/saved-parking-lots[/{lotId}]
5. user_vehicles
- 役割:ユーザー車両。車種・ナンバーを保持。駐車セッション開始時に選択する
- Role: User vehicles (type + plate). Selected when starting a parking session
- モバイルの操作:
GET/POST/PATCH/DELETE /v1/me/vehicles[/{id}](削除はソフトデリート) - Mobile ops:
GET/POST/PATCH/DELETE /v1/me/vehicles[/{id}](delete is soft)
6. user_push_tokens (重要)
- 役割:FCM デバイストークン。プッシュ通知の配信先
- Role: FCM device tokens — the destination for push delivery
- モバイルの操作:
PUT /v1/me/push-tokens(起動時・権限取得時に必ず upsert) - Mobile ops:
PUT /v1/me/push-tokens(upsert on launch and after permission grant) - ライフサイクル:ログアウト時にトークンを delete、ログイン時に upsert。アプリバージョン更新時も upsert
- Lifecycle: Delete on logout, upsert on login, upsert on app version change
7. user_notifications
- 役割:受信済み通知の永続化。アプリ内通知一覧の表示元
- Role: Persisted notifications shown on the in-app list
- モバイルの操作:
GET /v1/me/notifications(一覧)/PATCH .../{id}/read(既読化) - Mobile ops:
GET /v1/me/notifications,PATCH .../{id}/read - 種別(
notif_type):18 種類(詳細は mobile-app/notifications.html) - Types (
notif_type): 18 kinds (see mobile-app/notifications.html)
8. user_subscriptions
- 役割:IAP 購読状態(Apple / Google)
- Role: IAP subscription state (Apple / Google)
- モバイルの操作:
GET /v1/me/subscription(現状)/POST /v1/me/subscription/verify-iap(購入後レシート検証) - Mobile ops:
GET /v1/me/subscription/POST /v1/me/subscription/verify-iap(after purchase)
9. user_search_presets
- 役割:検索条件プリセット(フィルタの組み合わせ + 既定フラグ)
- Role: Saved search presets (filter combinations + default flag)
- モバイルの操作:
GET/POST/PATCH/DELETE /v1/me/search-presets[/{id}] - Mobile ops:
GET/POST/PATCH/DELETE /v1/me/search-presets[/{id}]
10. user_exp / user_badges(読み取り専用)
- 役割:ゲーミフィケーション。EXP とバッジ
- Role: Gamification — EXP and badges
- モバイルの操作:
GET /v1/me/exp/GET /v1/me/badges - Mobile ops:
GET /v1/me/exp,GET /v1/me/badges - 注意:書き込みはサーバー側で DB トリガが担当(駐車セッション完了などをトリガに自動付与)。モバイルから直接付与はできません
- Note: Writes are handled by server-side DB triggers (granted on session completion, etc.). Mobile cannot write directly
11. reviews
- 役割:駐車場レビュー。星評価と本文、
review_status(pending/approved/rejected) - Role: Parking-lot reviews — rating + text +
review_status(pending/approved/rejected) - モバイルの操作:
POST /v1/parking-lots/{id}/reviews(投稿はpendingで作成)/GET /v1/parking-lots/{id}/reviews(approvedのみ取得) - Mobile ops:
POST /v1/parking-lots/{id}/reviews(posted aspending),GET /v1/parking-lots/{id}/reviews(approvedonly)
12. assets(参照のみ)
- 役割:R2 に保存したファイルのメタデータ。モバイルはレビュー写真・駐車メモ写真のアップロード時に間接的に作成
- Role: Metadata for files stored in R2. Created indirectly when the mobile app uploads a review photo or parking memo
- モバイルの操作:
POST /v1/storage/upload-url(presigned PUT URL 取得時にasset_idも返る) → PUT →assets.idを関連テーブル(parking_sessions.memo_photo_asset_idなど)に紐付け - Mobile ops:
POST /v1/storage/upload-url(returns both presigned URL andasset_id) → PUT → linkassets.idto the parent record (e.g.parking_sessions.memo_photo_asset_id)
コードマスター(codes)の扱い
Working with the code master (codes)
上の表で code と書かれている列(user_status、vehicle_type、session_status、
notif_type、review_status など)は、日本語ラベルではなくコード値(英語小文字)で保存されます。
表示ラベルは codes テーブルで管理されており、モバイルは GET /v1/codes(edge キャッシュ)で一括取得してローカル辞書として持っておきます。
Columns marked code above (user_status, vehicle_type, session_status,
notif_type, review_status, etc.) store code values (lower-case English), not display labels.
Display labels live in the codes table. The mobile app fetches them in bulk via GET /v1/codes (edge-cached)
and keeps a local dictionary.
日時・位置情報の扱い Datetimes and locations
- 日時:すべて ISO 8601 + UTC オフセット。Parky の表示 TZ は
Asia/Tokyo(詳細は 03. API 契約と認証) - Datetimes: All ISO 8601 with UTC offset. Parky's display TZ is
Asia/Tokyo(see 03. API contract & auth) - 位置情報:
parking_lots.locationは PostGIS のgeography(Point, 4326)。API レスポンスでは{ lat, lng }の JSON で返されます - Locations:
parking_lots.locationis PostGISgeography(Point, 4326), returned as JSON{ lat, lng }