home · contact · privacy
Re-order BaseModel methods for more meaningful grouping.
[plomtask] / scripts / init.sql
index 870e845c31827bd7400faea3e7ea877458493715..b2979a5e1dffeedf0445ef65e6a675ec50e9bfce 100644 (file)
@@ -1,16 +1,16 @@
 CREATE TABLE condition_descriptions (
-    parent_id INTEGER NOT NULL,
+    parent INTEGER NOT NULL,
     timestamp TEXT NOT NULL,
     description TEXT NOT NULL,
-    PRIMARY KEY (parent_id, timestamp),
-    FOREIGN KEY (parent_id) REFERENCES conditions(id)
+    PRIMARY KEY (parent, timestamp),
+    FOREIGN KEY (parent) REFERENCES conditions(id)
 );
 CREATE TABLE condition_titles (
-    parent_id INTEGER NOT NULL,
+    parent INTEGER NOT NULL,
     timestamp TEXT NOT NULL,
     title TEXT NOT NULL,
-    PRIMARY KEY (parent_id, timestamp),
-    FOREIGN KEY (parent_id) REFERENCES conditions(id)
+    PRIMARY KEY (parent, timestamp),
+    FOREIGN KEY (parent) REFERENCES conditions(id)
 );
 CREATE TABLE conditions (
     id INTEGER PRIMARY KEY,
@@ -28,20 +28,27 @@ CREATE TABLE process_conditions (
     FOREIGN KEY (condition) REFERENCES conditions(id)
 );
 CREATE TABLE process_descriptions (
-    parent_id INTEGER NOT NULL,
+    parent INTEGER NOT NULL,
     timestamp TEXT NOT NULL,
     description TEXT NOT NULL,
-    PRIMARY KEY (parent_id, timestamp),
-    FOREIGN KEY (parent_id) REFERENCES processes(id)
+    PRIMARY KEY (parent, timestamp),
+    FOREIGN KEY (parent) REFERENCES processes(id)
+);
+CREATE TABLE process_disables (
+    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_efforts (
-    parent_id INTEGER NOT NULL,
+    parent INTEGER NOT NULL,
     timestamp TEXT NOT NULL,
     effort REAL NOT NULL,
-    PRIMARY KEY (parent_id, timestamp),
-    FOREIGN KEY (parent_id) REFERENCES processes(id)
+    PRIMARY KEY (parent, timestamp),
+    FOREIGN KEY (parent) REFERENCES processes(id)
 );
-CREATE TABLE process_fulfills (
+CREATE TABLE process_enables (
     process INTEGER NOT NULL,
     condition INTEGER NOT NULL,
     PRIMARY KEY(process, condition),
@@ -50,26 +57,19 @@ CREATE TABLE process_fulfills (
 );
 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)
+    owner INTEGER NOT NULL,
+    step_process INTEGER NOT NULL,
+    parent_step INTEGER,
+    FOREIGN KEY (owner) REFERENCES processes(id),
+    FOREIGN KEY (step_process) REFERENCES processes(id),
+    FOREIGN KEY (parent_step) REFERENCES process_steps(step_id)
 );
 CREATE TABLE process_titles (
-    parent_id INTEGER NOT NULL,
+    parent 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)
+    PRIMARY KEY (parent, timestamp),
+    FOREIGN KEY (parent) REFERENCES processes(id)
 );
 CREATE TABLE processes (
     id INTEGER PRIMARY KEY
@@ -88,14 +88,14 @@ CREATE TABLE todo_conditions (
     FOREIGN KEY (todo) REFERENCES todos(id),
     FOREIGN KEY (condition) REFERENCES conditions(id)
 );
-CREATE TABLE todo_fulfills (
+CREATE TABLE todo_disables (
     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 (
+CREATE TABLE todo_enables (
     todo INTEGER NOT NULL,
     condition INTEGER NOT NULL,
     PRIMARY KEY(todo, condition),
@@ -104,9 +104,9 @@ CREATE TABLE todo_undoes (
 );
 CREATE TABLE todos (
     id INTEGER PRIMARY KEY,
-    process_id INTEGER NOT NULL,
+    process INTEGER NOT NULL,
     is_done BOOLEAN NOT NULL,
     day TEXT NOT NULL,
-    FOREIGN KEY (process_id) REFERENCES processes(id),
+    FOREIGN KEY (process) REFERENCES processes(id),
     FOREIGN KEY (day) REFERENCES days(id)
 );