- Migration 092: ai_user_memory (per-user facts with expiry) - Migration 093: ai_conversation_summary (auto-generated summaries) - SQLAlchemy models: AIUserMemory, AIConversationSummary Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
18 lines
730 B
SQL
18 lines
730 B
SQL
-- 093_ai_conversation_summary.sql
|
|
-- Auto-generated summaries of AI conversations for memory context
|
|
|
|
CREATE TABLE IF NOT EXISTS ai_conversation_summary (
|
|
id SERIAL PRIMARY KEY,
|
|
conversation_id INTEGER NOT NULL UNIQUE REFERENCES ai_chat_conversations(id) ON DELETE CASCADE,
|
|
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
summary TEXT NOT NULL,
|
|
key_topics JSONB DEFAULT '[]',
|
|
created_at TIMESTAMP DEFAULT NOW(),
|
|
updated_at TIMESTAMP DEFAULT NOW()
|
|
);
|
|
|
|
CREATE INDEX idx_ai_conv_summary_user ON ai_conversation_summary(user_id, created_at DESC);
|
|
|
|
GRANT ALL ON TABLE ai_conversation_summary TO nordabiz_app;
|
|
GRANT USAGE, SELECT ON SEQUENCE ai_conversation_summary_id_seq TO nordabiz_app;
|