Skip to content

Commit 5505076

Browse files
authored
chore(db): drop legacy copilot_chats.messages JSONB column (#4886)
Reads and writes are fully cut over to the normalized copilot_messages table (verified in production: no writes to the column in 24h, recently-active chats have empty JSONB while copilot_messages holds the transcript). Drop the dead column via drizzle migration 0225 and re-type CopilotChatDetailRow.messages as an assembled (non-column) field. Deploy notes: reconcile any chats where the JSONB still leads copilot_messages before applying, and pg_repack copilot_chats afterward to reclaim the ~5.7GB TOAST storage (DROP COLUMN is metadata-only).
1 parent 71f6936 commit 5505076

5 files changed

Lines changed: 17228 additions & 3 deletions

File tree

apps/sim/lib/copilot/chat/lifecycle.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,14 @@ export type CopilotChatDetailRow = Pick<
101101
| 'workspaceId'
102102
| 'type'
103103
| 'title'
104-
| 'messages'
105104
| 'conversationId'
106105
| 'resources'
107106
| 'createdAt'
108107
| 'updatedAt'
109-
>
108+
> & {
109+
/** Transcript assembled from `copilot_messages` (no longer a chat-row column). */
110+
messages: unknown[]
111+
}
110112

111113
export type CopilotChatLegacyDetailRow = CopilotChatDetailRow &
112114
Pick<typeof copilotChats.$inferSelect, 'model' | 'planArtifact' | 'config'>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE "copilot_chats" DROP COLUMN "messages";

0 commit comments

Comments
 (0)