diff --git a/prisma/migrations/0114_v1110_coach_conversation_summary/migration.sql b/prisma/migrations/0114_v1110_coach_conversation_summary/migration.sql new file mode 100644 index 000000000..2a64ecf01 --- /dev/null +++ b/prisma/migrations/0114_v1110_coach_conversation_summary/migration.sql @@ -0,0 +1,5 @@ +-- v1.11.0 — rolling encrypted conversation summary for the Coach. +-- Additive only; safe on a populated table (nullable + defaulted). +ALTER TABLE "coach_conversations" ADD COLUMN IF NOT EXISTS "summary_encrypted" BYTEA; +ALTER TABLE "coach_conversations" ADD COLUMN IF NOT EXISTS "summary_updated_at" TIMESTAMP(3); +ALTER TABLE "coach_conversations" ADD COLUMN IF NOT EXISTS "summary_turn_count" INTEGER NOT NULL DEFAULT 0; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 35bfcc8b9..232978bfb 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -2629,6 +2629,13 @@ model CoachConversation { createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") + // v1.11.0 — rolling encrypted summary of the elided older turns, so a long + // conversation keeps memory of what came before without re-sending every + // turn to the provider. AES-256-GCM (same codec as CoachMessage.encrypted). + summaryEncrypted Bytes? @map("summary_encrypted") + summaryUpdatedAt DateTime? @map("summary_updated_at") + summaryTurnCount Int @default(0) @map("summary_turn_count") + user User @relation(fields: [userId], references: [id], onDelete: Cascade) messages CoachMessage[]