From 8daa6e774a6e02698c90392e7b2008542f789594 Mon Sep 17 00:00:00 2001
From: Kujtim Hoxha <kujtimii.h@gmail.com>
Date: Sun, 23 Mar 2025 19:19:08 +0100
Subject: add initial stuff

---
 internal/db/sql/sessions.sql | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 internal/db/sql/sessions.sql

(limited to 'internal/db/sql/sessions.sql')

diff --git a/internal/db/sql/sessions.sql b/internal/db/sql/sessions.sql
new file mode 100644
index 000000000..e90e5e328
--- /dev/null
+++ b/internal/db/sql/sessions.sql
@@ -0,0 +1,43 @@
+-- sqlfluff:dialect:sqlite
+-- name: CreateSession :one
+INSERT INTO sessions (
+    id,
+    title,
+    message_count,
+    tokens,
+    cost,
+    updated_at,
+    created_at
+) VALUES (
+    ?,
+    ?,
+    ?,
+    ?,
+    ?,
+    strftime('%s', 'now'),
+    strftime('%s', 'now')
+) RETURNING *;
+
+-- name: GetSessionByID :one
+SELECT *
+FROM sessions
+WHERE id = ? LIMIT 1;
+
+-- name: ListSessions :many
+SELECT *
+FROM sessions
+ORDER BY created_at DESC;
+
+-- name: UpdateSession :one
+UPDATE sessions
+SET
+    title = ?,
+    tokens = ?,
+    cost = ?
+WHERE id = ?
+RETURNING *;
+
+
+-- name: DeleteSession :exec
+DELETE FROM sessions
+WHERE id = ?;
-- 
cgit v1.2.3

