1-- name: CreateSession :one
2INSERT INTO sessions (
3 id,
4 parent_session_id,
5 title,
6 message_count,
7 prompt_tokens,
8 completion_tokens,
9 cost,
10 updated_at,
11 created_at
12) VALUES (
13 ?,
14 ?,
15 ?,
16 ?,
17 ?,
18 ?,
19 ?,
20 strftime('%s', 'now'),
21 strftime('%s', 'now')
22) RETURNING *;
23
24-- name: GetSessionByID :one
25SELECT *
26FROM sessions
27WHERE id = ? LIMIT 1;
28
29-- name: ListSessions :many
30SELECT *
31FROM sessions
32WHERE parent_session_id is NULL
33ORDER BY created_at DESC;
34
35-- name: UpdateSession :one
36UPDATE sessions
37SET
38 title = ?,
39 prompt_tokens = ?,
40 completion_tokens = ?,
41 cost = ?
42WHERE id = ?
43RETURNING *;
44
45
46-- name: DeleteSession :exec
47DELETE FROM sessions
48WHERE id = ?;