-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sql
More file actions
33 lines (26 loc) · 824 Bytes
/
Copy pathsetup.sql
File metadata and controls
33 lines (26 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
DROP TABLE IF EXISTS tasks;
CREATE TABLE tasks (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
description TEXT,
category TEXT NOT NULL,
importance TEXT NOT NULL DEFAULT 'medium'
CHECK (importance IN ('low', 'medium', 'high')),
status TEXT NOT NULL DEFAULT 'unfinished'
CHECK (status IN ('unfinished', 'finished')),
date_finished TEXT DEFAULT NULL,
deadline TEXT,
-- auto set on insert
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
-- auto set on insert + updated via trigger
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
);
-- auto-update on every update
CREATE TRIGGER update_tasks_updated_at
AFTER UPDATE ON tasks
FOR EACH ROW
BEGIN
UPDATE tasks
SET updated_at = CURRENT_TIMESTAMP
WHERE id = OLD.id;
END;