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    summary_message_id,
11    updated_at,
12    created_at
13) VALUES (
14    ?,
15    ?,
16    ?,
17    ?,
18    ?,
19    ?,
20    ?,
21    null,
22    strftime('%s', 'now'),
23    strftime('%s', 'now')
24) RETURNING *;
25
26-- name: GetSessionByID :one
27SELECT *
28FROM sessions
29WHERE id = ? LIMIT 1;
30
31-- name: ListSessions :many
32SELECT *
33FROM sessions
34WHERE parent_session_id is NULL
35ORDER BY created_at DESC;
36
37-- name: UpdateSession :one
38UPDATE sessions
39SET
40    title = ?,
41    prompt_tokens = ?,
42    completion_tokens = ?,
43    summary_message_id = ?,
44    cost = ?
45WHERE id = ?
46RETURNING *;
47
48
49-- name: DeleteSession :exec
50DELETE FROM sessions
51WHERE id = ?;