Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions scripts/backfill/__tests__/migrateRoom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ describe("migrateRoom", () => {
const stats = await migrateRoom(room, { dryRun: false });

expect(insertSession).toHaveBeenCalledTimes(1);
expect(insertSession).toHaveBeenCalledWith(
expect.objectContaining({
account_id: "acc-1",
artist_id: null,
}),
);
expect(insertChat).toHaveBeenCalledTimes(1);
// one batch call containing only the well-formed message
expect(upsertChatMessages).toHaveBeenCalledTimes(1);
Expand All @@ -102,6 +108,12 @@ describe("migrateRoom", () => {
expect(insertChat).not.toHaveBeenCalled();
});

it("passes room.artist_id into insertSession for straggler rooms", async () => {
await migrateRoom({ ...room, artist_id: "artist-1" }, { dryRun: false });

expect(insertSession).toHaveBeenCalledWith(expect.objectContaining({ artist_id: "artist-1" }));
});

it("skips session/chat inserts when they already exist (idempotent re-run)", async () => {
vi.mocked(selectSessions).mockResolvedValue([{ id: "s1" } as any]);

Expand Down
1 change: 1 addition & 0 deletions scripts/backfill/migrateRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export async function migrateRoom(
const session = await insertSession({
id: sessionId,
account_id: room.account_id,
artist_id: room.artist_id,
title,
created_at: room.updated_at,
updated_at: room.updated_at,
Expand Down
Loading