refactor(database): make session id the primary key in sessions table

This commit is contained in:
Haileyesus
2026-04-29 18:06:58 +03:00
parent f175d20c4e
commit cd3e8986d7
3 changed files with 49 additions and 24 deletions

View File

@@ -55,7 +55,8 @@ export const sessionsDb = {
db.prepare(
`INSERT INTO sessions (session_id, provider, custom_name, project_path, jsonl_path, created_at, updated_at)
VALUES (?, ?, ?, ?, ?, COALESCE(?, CURRENT_TIMESTAMP), COALESCE(?, CURRENT_TIMESTAMP))
ON CONFLICT(session_id, provider) DO UPDATE SET
ON CONFLICT(session_id) DO UPDATE SET
provider = excluded.provider,
updated_at = excluded.updated_at,
project_path = excluded.project_path,
jsonl_path = excluded.jsonl_path,
@@ -82,15 +83,6 @@ export const sessionsDb = {
).run(customName, sessionId);
},
createSessionName(sessionId: string, provider: string, customName: string): void {
const db = getConnection();
db.prepare(
`UPDATE sessions
SET custom_name = ?
WHERE session_id = ? AND provider = ?`
).run(customName, sessionId, provider);
},
getSessionById(sessionId: string): SessionMetadataLookupRow | null {
const db = getConnection();
const row = db