diff --git a/scripts/backfill/__tests__/migrateRoom.test.ts b/scripts/backfill/__tests__/migrateRoom.test.ts index 40bd58ea..5da4d8c9 100644 --- a/scripts/backfill/__tests__/migrateRoom.test.ts +++ b/scripts/backfill/__tests__/migrateRoom.test.ts @@ -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); @@ -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]); diff --git a/scripts/backfill/migrateRoom.ts b/scripts/backfill/migrateRoom.ts index 79f8c192..66fa13d8 100644 --- a/scripts/backfill/migrateRoom.ts +++ b/scripts/backfill/migrateRoom.ts @@ -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,