X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/balance2?a=blobdiff_plain;f=scripts%2Finit.sql;h=870e845c31827bd7400faea3e7ea877458493715;hb=5a5d713ce0b223ab2f6ef34c15bb82b614bdda98;hp=1aba8a4315577827f28bcc3296bbfe61c85e27e6;hpb=78d82605facbfd468584f7cc6e6f5515af4be8be;p=plomtask diff --git a/scripts/init.sql b/scripts/init.sql index 1aba8a4..870e845 100644 --- a/scripts/init.sql +++ b/scripts/init.sql @@ -1,3 +1,112 @@ +CREATE TABLE condition_descriptions ( + parent_id INTEGER NOT NULL, + timestamp TEXT NOT NULL, + description TEXT NOT NULL, + PRIMARY KEY (parent_id, timestamp), + FOREIGN KEY (parent_id) REFERENCES conditions(id) +); +CREATE TABLE condition_titles ( + parent_id INTEGER NOT NULL, + timestamp TEXT NOT NULL, + title TEXT NOT NULL, + PRIMARY KEY (parent_id, timestamp), + FOREIGN KEY (parent_id) REFERENCES conditions(id) +); +CREATE TABLE conditions ( + id INTEGER PRIMARY KEY, + is_active BOOLEAN NOT NULL +); CREATE TABLE days ( - date TEXT PRIMARY KEY + id TEXT PRIMARY KEY, + comment TEXT NOT NULL +); +CREATE TABLE process_conditions ( + process INTEGER NOT NULL, + condition INTEGER NOT NULL, + PRIMARY KEY (process, condition), + FOREIGN KEY (process) REFERENCES processes(id), + FOREIGN KEY (condition) REFERENCES conditions(id) +); +CREATE TABLE process_descriptions ( + parent_id INTEGER NOT NULL, + timestamp TEXT NOT NULL, + description TEXT NOT NULL, + PRIMARY KEY (parent_id, timestamp), + FOREIGN KEY (parent_id) REFERENCES processes(id) +); +CREATE TABLE process_efforts ( + parent_id INTEGER NOT NULL, + timestamp TEXT NOT NULL, + effort REAL NOT NULL, + PRIMARY KEY (parent_id, timestamp), + FOREIGN KEY (parent_id) REFERENCES processes(id) +); +CREATE TABLE process_fulfills ( + process INTEGER NOT NULL, + condition INTEGER NOT NULL, + PRIMARY KEY(process, condition), + FOREIGN KEY (process) REFERENCES processes(id), + FOREIGN KEY (condition) REFERENCES conditions(id) +); +CREATE TABLE process_steps ( + id INTEGER PRIMARY KEY, + owner_id INTEGER NOT NULL, + step_process_id INTEGER NOT NULL, + parent_step_id INTEGER, + FOREIGN KEY (owner_id) REFERENCES processes(id), + FOREIGN KEY (step_process_id) REFERENCES processes(id), + FOREIGN KEY (parent_step_id) REFERENCES process_steps(step_id) +); +CREATE TABLE process_titles ( + parent_id INTEGER NOT NULL, + timestamp TEXT NOT NULL, + title TEXT NOT NULL, + PRIMARY KEY (parent_id, timestamp), + FOREIGN KEY (parent_id) REFERENCES processes(id) +); +CREATE TABLE process_undoes ( + process INTEGER NOT NULL, + condition INTEGER NOT NULL, + PRIMARY KEY(process, condition), + FOREIGN KEY (process) REFERENCES processes(id), + FOREIGN KEY (condition) REFERENCES conditions(id) +); +CREATE TABLE processes ( + id INTEGER PRIMARY KEY +); +CREATE TABLE todo_children ( + parent INTEGER NOT NULL, + child INTEGER NOT NULL, + PRIMARY KEY (parent, child), + FOREIGN KEY (parent) REFERENCES todos(id), + FOREIGN KEY (child) REFERENCES todos(id) +); +CREATE TABLE todo_conditions ( + todo INTEGER NOT NULL, + condition INTEGER NOT NULL, + PRIMARY KEY(todo, condition), + FOREIGN KEY (todo) REFERENCES todos(id), + FOREIGN KEY (condition) REFERENCES conditions(id) +); +CREATE TABLE todo_fulfills ( + todo INTEGER NOT NULL, + condition INTEGER NOT NULL, + PRIMARY KEY(todo, condition), + FOREIGN KEY (todo) REFERENCES todos(id), + FOREIGN KEY (condition) REFERENCES conditions(id) +); +CREATE TABLE todo_undoes ( + todo INTEGER NOT NULL, + condition INTEGER NOT NULL, + PRIMARY KEY(todo, condition), + FOREIGN KEY (todo) REFERENCES todos(id), + FOREIGN KEY (condition) REFERENCES conditions(id) +); +CREATE TABLE todos ( + id INTEGER PRIMARY KEY, + process_id INTEGER NOT NULL, + is_done BOOLEAN NOT NULL, + day TEXT NOT NULL, + FOREIGN KEY (process_id) REFERENCES processes(id), + FOREIGN KEY (day) REFERENCES days(id) );