tas/database/schema.sql

36 lines
729 B
SQL

CREATE TABLE _tas_info (
version INTEGER PRIMARY KEY
);
CREATE TABLE tasks (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
project TEXT ,
link TEXT ,
dir_path TEXT ,
current BOOLEAN NOT NULL DEFAULT false,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
finished_at DATETIME
);
CREATE VIEW active_tasks
AS
SELECT
t.*,
row_number() OVER (ORDER BY t.created_at) AS idx
FROM tasks AS t
WHERE t.finished_at IS NULL
ORDER BY t.created_at
;
CREATE VIEW finished_tasks
AS
SELECT
t.*,
row_number() OVER (ORDER BY t.finished_at DESC) AS idx
FROM tasks AS t
WHERE t.finished_at IS NOT NULL
ORDER BY t.finished_at DESC
;