From 7ba68d333bc20b5795ccfd3870546a05eee60470 Mon Sep 17 00:00:00 2001
From: T <t@tjp.lol>
Date: Mon, 29 Sep 2025 15:04:44 -0600
Subject: Support for archiving clients and projects.

---
 internal/database/queries.sql | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

(limited to 'internal/database/queries.sql')

diff --git a/internal/database/queries.sql b/internal/database/queries.sql
index 4ed5578..c3a356c 100644
--- a/internal/database/queries.sql
+++ b/internal/database/queries.sql
@@ -4,9 +4,9 @@ values (@name, @email, @billable_rate)
 returning *;
 
 -- name: FindClient :many
-select c1.id, c1.name, c1.email, c1.billable_rate, c1.created_at from client c1 where c1.id = cast(@id as integer)
+select c1.id, c1.name, c1.email, c1.billable_rate, c1.archived, c1.created_at from client c1 where c1.id = cast(@id as integer)
 union all
-select c2.id, c2.name, c2.email, c2.billable_rate, c2.created_at from client c2 where c2.name = @name;
+select c2.id, c2.name, c2.email, c2.billable_rate, c2.archived, c2.created_at from client c2 where c2.name = @name;
 
 -- name: CreateProject :one
 insert into project (name, client_id, billable_rate)
@@ -14,9 +14,9 @@ values (@name, @client_id, @billable_rate)
 returning *;
 
 -- name: FindProject :many
-select p1.id, p1.name, p1.client_id, p1.billable_rate, p1.created_at from project p1 where p1.id = cast(@id as integer)
+select p1.id, p1.name, p1.client_id, p1.billable_rate, p1.archived, p1.created_at from project p1 where p1.id = cast(@id as integer)
 union all
-select p2.id, p2.name, p2.client_id, p2.billable_rate, p2.created_at from project p2 where p2.name = @name;
+select p2.id, p2.name, p2.client_id, p2.billable_rate, p2.archived, p2.created_at from project p2 where p2.name = @name;
 
 -- name: CreateTimeEntry :one
 insert into time_entry (start_time, description, client_id, project_id, billable_rate)
@@ -327,3 +327,23 @@ where id = @entry_id;
 -- name: RemoveTimeEntry :exec
 delete from time_entry
 where id = @entry_id;
+
+-- name: ArchiveClient :exec
+update client
+set archived = 1
+where id = @id;
+
+-- name: UnarchiveClient :exec
+update client
+set archived = 0
+where id = @id;
+
+-- name: ArchiveProject :exec
+update project
+set archived = 1
+where id = @id;
+
+-- name: UnarchiveProject :exec
+update project
+set archived = 0
+where id = @id;
-- 
cgit v1.2.3

