feat: add session move endpoint and project-session cascading delete

- Add sessions table to database with projectId and deletedAt columns
- Create POST /api/sessions/:id/move endpoint to reassign sessions
- Update DELETE /api/projects/:id to cascade soft-delete to sessions
- Support moving sessions between projects or to unassigned state
- Handle both active (in-memory) and historical sessions

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
uroma
2026-01-19 16:55:15 +00:00
Unverified
parent 76d914397f
commit 1fbc565a66
6 changed files with 2335 additions and 0 deletions

View File

@@ -48,6 +48,26 @@ function initializeDatabase() {
CREATE INDEX IF NOT EXISTS idx_projects_name ON projects(name)
`);
// Create sessions table
db.exec(`
CREATE TABLE IF NOT EXISTS sessions (
id TEXT PRIMARY KEY,
projectId INTEGER NULL,
deletedAt TEXT NULL,
FOREIGN KEY (projectId) REFERENCES projects(id) ON DELETE SET NULL
)
`);
// Create index on projectId for efficient session queries
db.exec(`
CREATE INDEX IF NOT EXISTS idx_sessions_projectId ON sessions(projectId)
`);
// Create index on deletedAt for efficient soft-delete queries
db.exec(`
CREATE INDEX IF NOT EXISTS idx_sessions_deletedAt ON sessions(deletedAt)
`);
return db;
}