SuperCoder/internal/db/sql/sessions.sql

52 lines
789 B
MySQL
Raw Normal View History

2025-03-23 19:19:08 +01:00
-- name: CreateSession :one
INSERT INTO sessions (
id,
2025-03-27 22:35:48 +01:00
parent_session_id,
2025-03-23 19:19:08 +01:00
title,
message_count,
2025-03-23 22:25:31 +01:00
prompt_tokens,
completion_tokens,
2025-03-23 19:19:08 +01:00
cost,
summary_message_id,
2025-03-23 19:19:08 +01:00
updated_at,
created_at
) VALUES (
?,
?,
?,
?,
?,
2025-03-23 22:25:31 +01:00
?,
2025-03-27 22:35:48 +01:00
?,
null,
2025-03-23 19:19:08 +01:00
strftime('%s', 'now'),
strftime('%s', 'now')
) RETURNING *;
-- name: GetSessionByID :one
SELECT *
FROM sessions
WHERE id = ? LIMIT 1;
-- name: ListSessions :many
SELECT *
FROM sessions
2025-03-27 22:35:48 +01:00
WHERE parent_session_id is NULL
2025-03-23 19:19:08 +01:00
ORDER BY created_at DESC;
-- name: UpdateSession :one
UPDATE sessions
SET
title = ?,
2025-03-23 22:25:31 +01:00
prompt_tokens = ?,
completion_tokens = ?,
summary_message_id = ?,
2025-03-23 19:19:08 +01:00
cost = ?
WHERE id = ?
RETURNING *;
-- name: DeleteSession :exec
DELETE FROM sessions
WHERE id = ?;