sessions.sql

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