diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/Model/File.php | 2 | ||||
-rw-r--r-- | app/Model/Subtask.php | 2 | ||||
-rw-r--r-- | app/Model/TaskFinder.php | 10 | ||||
-rw-r--r-- | app/Schema/Mysql.php | 8 | ||||
-rw-r--r-- | app/Schema/Postgres.php | 8 | ||||
-rw-r--r-- | app/Schema/Sqlite.php | 8 |
6 files changed, 28 insertions, 10 deletions
diff --git a/app/Model/File.php b/app/Model/File.php index 1b9351db..f069c8cf 100644 --- a/app/Model/File.php +++ b/app/Model/File.php @@ -17,7 +17,7 @@ class File extends Base * * @var string */ - const TABLE = 'task_has_files'; + const TABLE = 'files'; /** * Events diff --git a/app/Model/Subtask.php b/app/Model/Subtask.php index 048594bd..aa4a6f81 100644 --- a/app/Model/Subtask.php +++ b/app/Model/Subtask.php @@ -19,7 +19,7 @@ class Subtask extends Base * * @var string */ - const TABLE = 'task_has_subtasks'; + const TABLE = 'subtasks'; /** * Task "done" status diff --git a/app/Model/TaskFinder.php b/app/Model/TaskFinder.php index 98ece4e1..7216e92a 100644 --- a/app/Model/TaskFinder.php +++ b/app/Model/TaskFinder.php @@ -80,11 +80,11 @@ class TaskFinder extends Base return $this->db ->table(Task::TABLE) ->columns( - '(SELECT count(*) FROM comments WHERE task_id=tasks.id) AS nb_comments', - '(SELECT count(*) FROM task_has_files WHERE task_id=tasks.id) AS nb_files', - '(SELECT count(*) FROM task_has_subtasks WHERE task_id=tasks.id) AS nb_subtasks', - '(SELECT count(*) FROM task_has_subtasks WHERE task_id=tasks.id AND status=2) AS nb_completed_subtasks', - '(SELECT count(*) FROM ' . TaskLink::TABLE . ' WHERE ' . TaskLink::TABLE . '.task_id = tasks.id) AS nb_links', + '(SELECT count(*) FROM '.Comment::TABLE.' WHERE task_id=tasks.id) AS nb_comments', + '(SELECT count(*) FROM '.File::TABLE.' WHERE task_id=tasks.id) AS nb_files', + '(SELECT count(*) FROM '.Subtask::TABLE.' WHERE '.Subtask::TABLE.'.task_id=tasks.id) AS nb_subtasks', + '(SELECT count(*) FROM '.Subtask::TABLE.' WHERE '.Subtask::TABLE.'.task_id=tasks.id AND status=2) AS nb_completed_subtasks', + '(SELECT count(*) FROM '.TaskLink::TABLE.' WHERE '.TaskLink::TABLE.'.task_id = tasks.id) AS nb_links', 'tasks.id', 'tasks.reference', 'tasks.title', diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php index eeab24d6..1c5cdc3a 100644 --- a/app/Schema/Mysql.php +++ b/app/Schema/Mysql.php @@ -6,7 +6,13 @@ use PDO; use Core\Security; use Model\Link; -const VERSION = 47; +const VERSION = 48; + +function version_48($pdo) +{ + $pdo->exec('RENAME TABLE task_has_files TO files'); + $pdo->exec('RENAME TABLE task_has_subtasks TO subtasks'); +} function version_47($pdo) { diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php index c3e8fbda..aa3f60f7 100644 --- a/app/Schema/Postgres.php +++ b/app/Schema/Postgres.php @@ -6,7 +6,13 @@ use PDO; use Core\Security; use Model\Link; -const VERSION = 28; +const VERSION = 29; + +function version_29($pdo) +{ + $pdo->exec('ALTER TABLE task_has_files RENAME TO files'); + $pdo->exec('ALTER TABLE task_has_subtasks RENAME TO subtasks'); +} function version_28($pdo) { diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php index eefa0ae1..6fc2d07e 100644 --- a/app/Schema/Sqlite.php +++ b/app/Schema/Sqlite.php @@ -6,7 +6,13 @@ use Core\Security; use PDO; use Model\Link; -const VERSION = 46; +const VERSION = 47; + +function version_47($pdo) +{ + $pdo->exec('ALTER TABLE task_has_files RENAME TO files'); + $pdo->exec('ALTER TABLE task_has_subtasks RENAME TO subtasks'); +} function version_46($pdo) { |