first commit

This commit is contained in:
Romulus21 committed 2026-10-26 13:21:14 +01:00
commit dd6a740645
37 files changed
+5424

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
-- Timestamps are stored as UTC text, always formatted as "YYYY-MM-DDTHH:MM:SSZ"
-- so that lexicographic comparison matches chronological order.
CREATE TABLE clients (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL UNIQUE,
archived INTEGER NOT NULL DEFAULT 0,
created_at TEXT NOT NULL
);
CREATE TABLE projects (
id INTEGER PRIMARY KEY,
client_id INTEGER NOT NULL REFERENCES clients (id) ON DELETE CASCADE,
name TEXT NOT NULL,
archived INTEGER NOT NULL DEFAULT 0,
created_at TEXT NOT NULL,
UNIQUE (client_id, name)
);
CREATE TABLE time_entries (
id INTEGER PRIMARY KEY,
project_id INTEGER NOT NULL REFERENCES projects (id) ON DELETE CASCADE,
started_at TEXT NOT NULL,
ended_at TEXT,
note TEXT NOT NULL DEFAULT '',
CHECK (ended_at IS NULL OR ended_at > started_at)
);
-- At most one running timer: every running entry indexes the same value (1).
CREATE UNIQUE INDEX one_running_timer ON time_entries ((ended_at IS NULL)) WHERE ended_at IS NULL;
CREATE INDEX idx_entries_started ON time_entries (started_at);
CREATE INDEX idx_entries_project ON time_entries (project_id);
CREATE INDEX idx_projects_client ON projects (client_id);
+15
View File
@@ -0,0 +1,15 @@
-- Clients always have a color; projects inherit their client's color unless set.
ALTER TABLE clients ADD COLUMN color TEXT NOT NULL DEFAULT '#2f6f5e';
ALTER TABLE projects ADD COLUMN color TEXT;
-- Spread existing clients over the default palette (see repo::PALETTE).
UPDATE clients SET color = CASE (id - 1) % 8
WHEN 0 THEN '#2f6f5e'
WHEN 1 THEN '#3b6fb6'
WHEN 2 THEN '#c2410c'
WHEN 3 THEN '#7c3aed'
WHEN 4 THEN '#be185d'
WHEN 5 THEN '#a16207'
WHEN 6 THEN '#0e7490'
ELSE '#4d7c0f'
END;