condition = super().from_table_row(db_conn, row)
assert isinstance(condition, Condition)
for title_row in db_conn.exec('SELECT * FROM condition_titles '
- 'WHERE parent_id = ?', (row[0],)):
+ 'WHERE parent = ?', (row[0],)):
condition.title.history[title_row[1]]\
= title_row[2] # pylint: disable=no-member
for desc_row in db_conn.exec('SELECT * FROM condition_descriptions '
- 'WHERE parent_id = ?', (row[0],)):
+ 'WHERE parent = ?', (row[0],)):
condition.description.history[desc_row[1]]\
= desc_row[2] # pylint: disable=no-member
return condition
raise NotFoundException(f'Process not found of id: {id_}')
process = Process(id_)
for row in db_conn.exec('SELECT * FROM process_titles '
- 'WHERE parent_id = ?', (process.id_,)):
+ 'WHERE parent = ?', (process.id_,)):
process.title.history[row[1]] = row[2]
for row in db_conn.exec('SELECT * FROM process_descriptions '
- 'WHERE parent_id = ?', (process.id_,)):
+ 'WHERE parent = ?', (process.id_,)):
process.description.history[row[1]] = row[2]
for row in db_conn.exec('SELECT * FROM process_efforts '
- 'WHERE parent_id = ?', (process.id_,)):
+ 'WHERE parent = ?', (process.id_,)):
process.effort.history[row[1]] = row[2]
for row in db_conn.exec('SELECT * FROM process_steps '
- 'WHERE owner_id = ?', (process.id_,)):
+ 'WHERE owner = ?', (process.id_,)):
process.explicit_steps += [ProcessStep.from_table_row(db_conn,
row)]
for row in db_conn.exec('SELECT condition FROM process_conditions '
def used_as_step_by(self, db_conn: DatabaseConnection) -> list[Process]:
"""Return Processes using self for a ProcessStep."""
owner_ids = set()
- for owner_id in db_conn.exec('SELECT owner_id FROM process_steps WHERE'
- ' step_process_id = ?', (self.id_,)):
+ for owner_id in db_conn.exec('SELECT owner FROM process_steps WHERE'
+ ' step_process = ?', (self.id_,)):
owner_ids.add(owner_id[0])
return [self.__class__.by_id(db_conn, id_) for id_ in owner_ids]
assert isinstance(step.id_, int)
del db_conn.cached_process_steps[step.id_]
self.explicit_steps = []
- db_conn.exec('DELETE FROM process_steps WHERE owner_id = ?',
+ db_conn.exec('DELETE FROM process_steps WHERE owner = ?',
(self.id_,))
for step_tuple in steps:
self._add_step(db_conn, step_tuple[0],
db_conn.exec('INSERT INTO process_undoes VALUES (?,?)',
(self.id_, condition.id_))
assert isinstance(self.id_, int)
- db_conn.exec('DELETE FROM process_steps WHERE owner_id = ?',
+ db_conn.exec('DELETE FROM process_steps WHERE owner = ?',
(self.id_,))
for step in self.explicit_steps:
step.save(db_conn)
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,
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_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 (
process INTEGER NOT NULL,
);
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)
+ PRIMARY KEY (parent, timestamp),
+ FOREIGN KEY (parent) REFERENCES processes(id)
);
CREATE TABLE process_undoes (
process INTEGER NOT NULL,
);
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)
);