summaryrefslogtreecommitdiff
path: root/internal/database
diff options
context:
space:
mode:
Diffstat (limited to 'internal/database')
-rw-r--r--internal/database/queries.sql28
-rw-r--r--internal/database/schema.sql2
2 files changed, 26 insertions, 4 deletions
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;
diff --git a/internal/database/schema.sql b/internal/database/schema.sql
index 84f4f02..31a5d0a 100644
--- a/internal/database/schema.sql
+++ b/internal/database/schema.sql
@@ -3,6 +3,7 @@ create table if not exists client (
name text not null unique,
email text,
billable_rate integer,
+ archived integer not null default 0,
created_at datetime default current_timestamp
);
@@ -11,6 +12,7 @@ create table if not exists project (
name text not null unique,
client_id integer not null,
billable_rate integer,
+ archived integer not null default 0,
created_at datetime default current_timestamp,
foreign key (client_id) references client(id)
);