Feat/phase 2 backfill rooms to sessions
Closed
AH
5mo ago+729+729+012345678901234567890123456789-8-8-0123456789
- Introduced a new script "backfill:rooms-to-sessions" to facilitate the backfilling process.
- Updated the "update-types" script for consistency.
Summary by cubic
Adds a Phase 2 backfill to migrate rooms into sessions, chats, and chat_messages. Preserves chat URLs, uses deterministic session IDs and stable pagination, and adds resilient message upserts. Run with pnpm backfill:rooms-to-sessions.
-
New Features
- Added
backfill:rooms-to-sessionsscript inpackage.json. - Migrates
rooms→sessions, keepsrooms.idaschats.id, movesmemories→chat_messages. - Paginated reads with secondary
idordering; deterministic session IDs (uuidv5). - Batch upserts for
chat_messageswith per-row retry; throws on count mismatches.
- Added
-
Refactors
- Moved all Supabase queries to
lib/supabase/<table>/*and sharedpaginate;migrateRoom+ entry script are orchestration only. - Reuse
serverClient; deleted duplicate backfill client. - Regenerated
types/database.types.tsto includesessions,chats,chat_messages. - Runs via
npx tsx; clearer errors; excludedscriptsfrom TS build.
- Moved all Supabase queries to
Summary by CodeRabbit
- Chores
- Added database helper utilities for managing chat messages, chats, sessions, and room data with conflict resolution handling
- Implemented pagination support for efficient retrieval of large datasets