auto-claude: subtask-4-4 - Create chat_sessions and chat_messages tables in Supabase

Create SQL migration for chatbot database tables:
- chat_sessions: Stores visitor session data with visitor_id, metadata, timestamps
- chat_messages: Stores chat messages with role (user/assistant/system), content
- Proper indexes for visitor lookup and message ordering
- Row Level Security (RLS) enabled with policies for:
  - Service role full access (for server-side API)
  - Visitor-based access via x-visitor-id header (for potential future client-side)
- Trigger for automatic updated_at column on chat_sessions

Also updated ChatSession interface in chat.ts to include updated_at field.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-25 00:53:55 +01:00
co-authored by Claude Opus 4.5
parent 32717916ea
commit f8fbac8ac6
2 changed files with 156 additions and 0 deletions
+1
View File
@@ -6,6 +6,7 @@ export type ChatRole = 'user' | 'assistant' | 'system';
export interface ChatSession {
id: string;
created_at: string;
updated_at: string;
visitor_id: string;
metadata: Record<string, unknown>;
}