-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.sql
30 lines (23 loc) · 830 Bytes
/
schema.sql
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
-- Copyright (c) 2021 Veera Lupunen
BEGIN;
CREATE TABLE IF NOT EXISTS worker (
id SERIAL PRIMARY KEY,
username VARCHAR(255) UNIQUE NOT NULL,
password TEXT NOT NULL);
CREATE TABLE IF NOT EXISTS entry (
id SERIAL PRIMARY KEY,
time_beg TIMESTAMP NOT NULL,
time_end TIMESTAMP,
pause FLOAT NOT NULL DEFAULT 0,
notes TEXT,
w_id INTEGER NOT NULL);
CREATE TABLE IF NOT EXISTS task (
id SERIAL PRIMARY KEY,
content TEXT NOT NULL);
CREATE TABLE IF NOT EXISTS worker_task (
w_id INTEGER REFERENCES worker(id) ON UPDATE CASCADE ON DELETE CASCADE,
t_id INTEGER REFERENCES task(id) ON UPDATE CASCADE ON DELETE CASCADE);
CREATE TABLE IF NOT EXISTS task_entry (
t_id INTEGER REFERENCES task(id) ON UPDATE CASCADE ON DELETE CASCADE,
e_id INTEGER REFERENCES entry(id) ON UPDATE CASCADE ON DELETE CASCADE);
COMMIT;