From 5c92f467867b43034b9e66b46b3b465ba9db655c Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 30 Jan 2016 20:38:20 -0500 Subject: Add external links for tasks with plugin api --- app/Schema/Mysql.php | 20 +++++++++++++++++++- app/Schema/Postgres.php | 20 +++++++++++++++++++- app/Schema/Sqlite.php | 20 +++++++++++++++++++- 3 files changed, 57 insertions(+), 3 deletions(-) (limited to 'app/Schema') diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php index 8f1db510..5433c751 100644 --- a/app/Schema/Mysql.php +++ b/app/Schema/Mysql.php @@ -6,7 +6,25 @@ use PDO; use Kanboard\Core\Security\Token; use Kanboard\Core\Security\Role; -const VERSION = 103; +const VERSION = 104; + +function version_104(PDO $pdo) +{ + $pdo->exec(" + CREATE TABLE task_has_external_links ( + id INT NOT NULL AUTO_INCREMENT, + link_type VARCHAR(100) NOT NULL, + dependency VARCHAR(100) NOT NULL, + title VARCHAR(255) NOT NULL, + url VARCHAR(255) NOT NULL, + date_creation INT NOT NULL, + date_modification INT NOT NULL, + task_id INT NOT NULL, + creator_id INT DEFAULT 0, + FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE + ) ENGINE=InnoDB CHARSET=utf8 + "); +} function version_103(PDO $pdo) { diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php index a7bf8054..363b633b 100644 --- a/app/Schema/Postgres.php +++ b/app/Schema/Postgres.php @@ -6,7 +6,25 @@ use PDO; use Kanboard\Core\Security\Token; use Kanboard\Core\Security\Role; -const VERSION = 83; +const VERSION = 84; + +function version_84(PDO $pdo) +{ + $pdo->exec(" + CREATE TABLE task_has_external_links ( + id SERIAL, + link_type VARCHAR(100) NOT NULL, + dependency VARCHAR(100) NOT NULL, + title VARCHAR(255) NOT NULL, + url VARCHAR(255) NOT NULL, + date_creation INT NOT NULL, + date_modification INT NOT NULL, + task_id INT NOT NULL, + creator_id INT DEFAULT 0, + FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE + ) + "); +} function version_83(PDO $pdo) { diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php index 08689749..bc701341 100644 --- a/app/Schema/Sqlite.php +++ b/app/Schema/Sqlite.php @@ -6,7 +6,25 @@ use Kanboard\Core\Security\Token; use Kanboard\Core\Security\Role; use PDO; -const VERSION = 95; +const VERSION = 96; + +function version_96(PDO $pdo) +{ + $pdo->exec(" + CREATE TABLE task_has_external_links ( + id INTEGER PRIMARY KEY, + link_type TEXT NOT NULL, + dependency TEXT NOT NULL, + title TEXT NOT NULL, + url TEXT NOT NULL, + date_creation INTEGER NOT NULL, + date_modification INTEGER NOT NULL, + task_id INTEGER NOT NULL, + creator_id INTEGER DEFAULT 0, + FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE + ) + "); +} function version_95(PDO $pdo) { -- cgit v1.2.3 From 4a52d327f7e555c336a428c457cf40c3d97bfab3 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 30 Jan 2016 20:54:07 -0500 Subject: Fix typo in Mysql migration --- app/Schema/Mysql.php | 3 +- tests/units/Model/TaskExternalLinkTest.php | 44 ------------------------------ 2 files changed, 2 insertions(+), 45 deletions(-) (limited to 'app/Schema') diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php index 5433c751..036958b6 100644 --- a/app/Schema/Mysql.php +++ b/app/Schema/Mysql.php @@ -21,7 +21,8 @@ function version_104(PDO $pdo) date_modification INT NOT NULL, task_id INT NOT NULL, creator_id INT DEFAULT 0, - FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE + FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE, + PRIMARY KEY(id) ) ENGINE=InnoDB CHARSET=utf8 "); } diff --git a/tests/units/Model/TaskExternalLinkTest.php b/tests/units/Model/TaskExternalLinkTest.php index b3f01759..28ccab83 100644 --- a/tests/units/Model/TaskExternalLinkTest.php +++ b/tests/units/Model/TaskExternalLinkTest.php @@ -54,50 +54,6 @@ class TaskExternalLinkTest extends Base $this->assertEquals(time(), $link['date_creation'], '', 2); } - public function testCreateWithNoType() - { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskExternalLinkModel = new TaskExternalLink($this->container); - - $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); - $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Test', 'project_id' => 1))); - $this->assertFalse($taskExternalLinkModel->create(array('task_id' => 1, 'id' => '', 'url' => 'http://kanboard.net/', 'title' => 'My website', 'dependency' => 'related'))); - } - - public function testCreateWithNoDependency() - { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskExternalLinkModel = new TaskExternalLink($this->container); - - $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); - $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Test', 'project_id' => 1))); - $this->assertFalse($taskExternalLinkModel->create(array('task_id' => 1, 'id' => '', 'url' => 'http://kanboard.net/', 'title' => 'My website', 'link_type' => 'test'))); - } - - public function testCreateWithNoTitle() - { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskExternalLinkModel = new TaskExternalLink($this->container); - - $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); - $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Test', 'project_id' => 1))); - $this->assertFalse($taskExternalLinkModel->create(array('task_id' => 1, 'id' => '', 'url' => 'http://kanboard.net/', 'link_type' => 'test', 'dependency' => 'test'))); - } - - public function testCreateWithNoUrl() - { - $projectModel = new Project($this->container); - $taskCreationModel = new TaskCreation($this->container); - $taskExternalLinkModel = new TaskExternalLink($this->container); - - $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); - $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Test', 'project_id' => 1))); - $this->assertFalse($taskExternalLinkModel->create(array('task_id' => 1, 'id' => '', 'title' => 'test', 'link_type' => 'test', 'dependency' => 'test'))); - } - public function testModification() { $projectModel = new Project($this->container); -- cgit v1.2.3