Repository navigation
refactor: データモデル整理 - #114
Merged
Merged
Conversation
フォームと API で同じスキーマを使っていたため、API 側で日時の形式を検証できず、 ISO 8601 でない値を送ると toIso() で RangeError になり 500 を返していた。 フォーム用 (YYYY-MM-DD / HH:mm) と API 用 (ISO 8601) にスキーマを分ける。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ホストが回答した場合の hosts / guests / mine、Slot の guestId、 PUT のレスポンス全体を検証する。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GET では browserId を外しているが、PUT /projects/:projectId/submissions/mine は 自分の回答をそのまま返していたため、browserId が含まれていた。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
指定したマイグレーションの直前まで当てた DB を用意し、旧スキーマのデータを入れてから 残りを当てられるようにする。共有の DB とは別の D1 を使う。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Slot の検証で使うタイムゾーンを、固定の Asia/Tokyo からイベントごとの値にする。 既存のイベントは Asia/Tokyo とし、作成日時はマイグレーションを当てた時刻で埋める。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
時間帯は日付を使わないので、イベントのタイムゾーンでの時刻だけを保存する。 既存の値は Asia/Tokyo の時刻に変換する。API は引き続き ISO 8601 で受け取って返し、 返すときの日付は Web UI と同じく、開始を初日、終了を最終日にする。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
時間帯は日付を使わないのに、API では ISO 8601 の日時でやりとりしていた。 日付を含めて前後を比べるため、初日 23:00〜最終日 08:00 のように時刻が逆転した 時間帯も通っていた。DB と同じくイベントのタイムゾーンでの "HH:mm" にし、 その日の終わりまでを表す "24:00" も選べるようにする。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PUT /projects/:id は全項目を省略できるのに、省略したときの扱いが項目ごとに 違っていた (説明と時間帯は消え、名前・日程・参加形態は残る)。部分更新として PATCH にし、省略したものは変えず、空文字や空配列を指定したときだけ消す。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c.json(204) としていたため、ステータスは 200 で本文が 204 という数値になっていた。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
日程は日付しか使わないのに、DB と API では開始日の 0:00 と終了日の 23:59:59.999 を UTC の日時にしてやりとりしていた。DB も API もイベントのタイムゾーンでの日付にし、 既存の値は Asia/Tokyo の日付に変換する。どのタイムゾーンでの値かが分かるよう、 レスポンスに timezone を含める。フォームと API で入力の形式が同じになったので、 検証のスキーマも 1 つにまとめる。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Project → event、AllowedRange → allowedRange、ParticipationOption → option、 Slot → slot。Host と Guest は participant にまとめるときに消すので変えない。 SQLite のテーブル名は大文字小文字を区別せず、大文字小文字だけ違う名前には 直接変えられないので、別の名前を経由する。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
allowedRange・option・slot の projectId を eventId に、slot の from / to / participationOptionId を startAt / endAt / optionId にし、インデックス名も 付け直す。slot のインデックスは、イベントの Slot を時刻順に読むので (eventId, startAt) にする。API の Slot も、送信は start / end、受信は from / to と 違っていたので、どちらも startAt / endAt / optionId にそろえる。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ホストとゲストを participant にまとめ、role で区別する。ホストが自分のイベントに
回答すると、Host と Guest の 2 行に分かれていたのを 1 行にする。name が null なら
まだ回答していない。slot は guestId の代わりに participantId で参加者を参照する。
API の hosts / guests / meAsGuest / guestId の形は保ち、projectId を eventId に、
回答の送信本文から重複していた projectId を消し、回答の送信と更新はどちらも
{ guest } を返すようにそろえる。
移行のテストの migrate() は対象のマイグレーションまでを当てるようにし、
後からマイグレーションを足しても前のテストが変わらないようにする。
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
画面上の呼び名 (イベント) と DB のテーブル名に合わせ、schema の export 名、 services と routes のファイル名・関数名、ServiceError の理由名を event にする。 participationOption も option にする。API の名前はまだ変えない。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
API のパスを /projects から /events に、パスの引数を :projectId から :eventId に、 参加形態のキーを participationOptions から options にする。Web UI の RPC の 呼び出しと、OG を作る Pages Functions の取得先も合わせて直す。 client の Project 型やページ・関数の名前も Event にする。Event は使うファイルで import するので、グローバルの DOM の Event 型とはぶつからない。 Pages Functions は API を /events で呼ぶので、Pages と Workers は同時にデプロイする。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
データモデルの節を足し、日付と時間帯の持ち方、participant の扱い、 マイグレーションの注意を書く。FullCalendar に渡すと書いていたカレンダーの 描画の流れと、参加形態の初期値の説明を今のコードに合わせ、RPC の例も /events に直す。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
サーバーを Workers に移したときに wrangler が server だけに入るようになり、 client で npx wrangler pages dev が見つからなくなっていた。client の devDependencies に server と同じ版の wrangler を足す。wrangler が求める版に 合わせて、client の @cloudflare/workers-types も server と同じ v5 にする。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.