server: reconcile ai_sessions persistence to Chunk 9 AISession shape

Reshape the ai_sessions table (migration 003) and mapping/routes to the
full AISession contract: title, kind, notes, created_at, last_message_at;
drop legacy role/model/settings. toAISession now maps the new columns and
routes create/patch/messages handlers use the new shape.
This commit is contained in:
Schwitzz
2026-10-29 15:03:32 -05:00
parent fc8eaa86c3
commit a1b5587fcb
15 changed files with 181 additions and 60 deletions
+24
View File
@@ -0,0 +1,24 @@
-- Chunk #9: reshape ai_sessions to the full AISession shape.
-- Adds title, kind, notes, created_at, last_message_at; drops role, model, settings.
CREATE TABLE ai_sessions_new (
id TEXT PRIMARY KEY,
project_id TEXT NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
title TEXT NOT NULL DEFAULT '',
kind TEXT NOT NULL DEFAULT 'session',
messages TEXT NOT NULL DEFAULT '[]',
suggestions TEXT NOT NULL DEFAULT '[]',
notes TEXT NOT NULL DEFAULT '[]',
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL,
last_message_at TEXT
);
INSERT INTO ai_sessions_new (id, project_id, title, kind, messages, suggestions, notes, created_at, updated_at, last_message_at)
SELECT id, project_id, '', 'session', messages, suggestions, '[]', updated_at, updated_at, NULL
FROM ai_sessions;
DROP TABLE ai_sessions;
ALTER TABLE ai_sessions_new RENAME TO ai_sessions;
CREATE INDEX IF NOT EXISTS idx_ai_sessions_project ON ai_sessions(project_id);