Skip to content

Commit bf24ad9

Browse files
committed
feat(ai-chat reference): db:reset:chats helper for clean smoke-test slates
The reference's Chat / ChatSession Postgres tables are shared between local and test cloud targets. A row created with one webapp's PAT and lastEventId is poison if you switch the .env to the other target and reuse the same chatId — the transport gets a 401 or resumes from a sequence that doesn't exist on the other backend. Adds: - prisma/reset-chats.sql: TRUNCATE Chat, ChatSession (User survives — it's upserted by onPreload/onChatStart anyway). - package.json db:reset:chats script wrapping prisma db execute --file. Run `pnpm run db:reset:chats` between target switches and at the top of every smoke test. Codified in the ai-chat-e2e skill as a required prereq.
1 parent 88b0b28 commit bf24ad9

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

references/ai-chat/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"db:migrate": "prisma migrate dev",
1111
"db:push": "prisma db push",
1212
"db:generate": "prisma generate",
13+
"db:reset:chats": "prisma db execute --file prisma/reset-chats.sql",
1314
"test": "vitest"
1415
},
1516
"dependencies": {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- Wipe customer-side chat state for a fresh smoke-test slate.
2+
-- Run via `pnpm run db:reset:chats`.
3+
-- Leaves User rows intact (they're upserted by onPreload/onChatStart),
4+
-- but clears every Chat + ChatSession so a chatId from one target
5+
-- (test cloud / local) can't carry stale session/PAT/lastEventId state
6+
-- into the other.
7+
TRUNCATE "Chat", "ChatSession";

0 commit comments

Comments
 (0)