From b24b1e7e4e5ee0551ee56aa0f21c4425b479db2e Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Wed, 4 Feb 2015 22:19:32 -0500 Subject: Add subtasks restrictions and time tracking --- app/Schema/Mysql.php | 22 +++++++++++++++++++++- app/Schema/Postgres.php | 21 ++++++++++++++++++++- app/Schema/Sqlite.php | 21 ++++++++++++++++++++- 3 files changed, 61 insertions(+), 3 deletions(-) (limited to 'app/Schema') diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php index 54aa748e..5a52288b 100644 --- a/app/Schema/Mysql.php +++ b/app/Schema/Mysql.php @@ -5,7 +5,27 @@ namespace Schema; use PDO; use Core\Security; -const VERSION = 42; +const VERSION = 43; + +function version_43($pdo) +{ + $rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)'); + $rq->execute(array('subtask_restriction', '0')); + $rq->execute(array('subtask_time_tracking', '0')); + + $pdo->exec(" + CREATE TABLE subtask_time_tracking ( + id INT NOT NULL AUTO_INCREMENT, + user_id INT NOT NULL, + subtask_id INT NOT NULL, + start INT DEFAULT 0, + end INT DEFAULT 0, + PRIMARY KEY(id), + FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY(subtask_id) REFERENCES task_has_subtasks(id) ON DELETE CASCADE + ) ENGINE=InnoDB CHARSET=utf8 + "); +} function version_42($pdo) { diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php index eb094f17..7aa1c457 100644 --- a/app/Schema/Postgres.php +++ b/app/Schema/Postgres.php @@ -5,7 +5,26 @@ namespace Schema; use PDO; use Core\Security; -const VERSION = 23; +const VERSION = 24; + +function version_24($pdo) +{ + $rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)'); + $rq->execute(array('subtask_restriction', '0')); + $rq->execute(array('subtask_time_tracking', '0')); + + $pdo->exec(" + CREATE TABLE subtask_time_tracking ( + id SERIAL PRIMARY KEY, + user_id INTEGER NOT NULL, + subtask_id INTEGER NOT NULL, + start INTEGER DEFAULT 0, + end INTEGER DEFAULT 0, + FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY(subtask_id) REFERENCES task_has_subtasks(id) ON DELETE CASCADE + ) + "); +} function version_23($pdo) { diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php index 16143646..17166e64 100644 --- a/app/Schema/Sqlite.php +++ b/app/Schema/Sqlite.php @@ -5,7 +5,26 @@ namespace Schema; use Core\Security; use PDO; -const VERSION = 41; +const VERSION = 42; + +function version_42($pdo) +{ + $rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)'); + $rq->execute(array('subtask_restriction', '0')); + $rq->execute(array('subtask_time_tracking', '0')); + + $pdo->exec(" + CREATE TABLE subtask_time_tracking ( + id INTEGER PRIMARY KEY, + user_id INTEGER NOT NULL, + subtask_id INTEGER NOT NULL, + start INTEGER DEFAULT 0, + end INTEGER DEFAULT 0, + FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY(subtask_id) REFERENCES task_has_subtasks(id) ON DELETE CASCADE + ) + "); +} function version_41($pdo) { -- cgit v1.2.3