summaryrefslogtreecommitdiff
path: root/app/Schema
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-06-23 20:26:19 -0400
committerFrederic Guillot <fred@kanboard.net>2016-06-23 20:26:19 -0400
commitd560f84b374fa1b3345dc582eddd6bb7b9138674 (patch)
treea7d9a429ee3094d530c8ca5dea2bda6709c08b82 /app/Schema
parent95751f391f336faf82ee2402a559247aef668e72 (diff)
Added models for tags
Diffstat (limited to 'app/Schema')
-rw-r--r--app/Schema/Mysql.php25
-rw-r--r--app/Schema/Postgres.php24
-rw-r--r--app/Schema/Sqlite.php24
3 files changed, 70 insertions, 3 deletions
diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php
index 934b063f..82ccb8c8 100644
--- a/app/Schema/Mysql.php
+++ b/app/Schema/Mysql.php
@@ -6,7 +6,30 @@ use PDO;
use Kanboard\Core\Security\Token;
use Kanboard\Core\Security\Role;
-const VERSION = 110;
+const VERSION = 111;
+
+function version_111(PDO $pdo)
+{
+ $pdo->exec("
+ CREATE TABLE tags (
+ id INT NOT NULL AUTO_INCREMENT,
+ name VARCHAR(255) NOT NULL,
+ project_id INT NOT NULL,
+ UNIQUE(project_id, name),
+ PRIMARY KEY(id)
+ ) ENGINE=InnoDB CHARSET=utf8
+ ");
+
+ $pdo->exec("
+ CREATE TABLE task_has_tags (
+ task_id INT NOT NULL,
+ tag_id INT NOT NULL,
+ FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE,
+ FOREIGN KEY(tag_id) REFERENCES tags(id) ON DELETE CASCADE,
+ UNIQUE(tag_id, task_id)
+ ) ENGINE=InnoDB CHARSET=utf8
+ ");
+}
function version_110(PDO $pdo)
{
diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php
index 3ef49498..229cbd25 100644
--- a/app/Schema/Postgres.php
+++ b/app/Schema/Postgres.php
@@ -6,7 +6,29 @@ use PDO;
use Kanboard\Core\Security\Token;
use Kanboard\Core\Security\Role;
-const VERSION = 89;
+const VERSION = 90;
+
+function version_90(PDO $pdo)
+{
+ $pdo->exec("
+ CREATE TABLE tags (
+ id SERIAL PRIMARY KEY,
+ name VARCHAR(255) NOT NULL,
+ project_id INTEGER NOT NULL,
+ UNIQUE(project_id, name)
+ )
+ ");
+
+ $pdo->exec("
+ CREATE TABLE task_has_tags (
+ task_id INTEGER NOT NULL,
+ tag_id INTEGER NOT NULL,
+ FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE,
+ FOREIGN KEY(tag_id) REFERENCES tags(id) ON DELETE CASCADE,
+ UNIQUE(tag_id, task_id)
+ )
+ ");
+}
function version_89(PDO $pdo)
{
diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php
index 9ded7ed9..dac348d4 100644
--- a/app/Schema/Sqlite.php
+++ b/app/Schema/Sqlite.php
@@ -6,7 +6,29 @@ use Kanboard\Core\Security\Token;
use Kanboard\Core\Security\Role;
use PDO;
-const VERSION = 101;
+const VERSION = 102;
+
+function version_102(PDO $pdo)
+{
+ $pdo->exec("
+ CREATE TABLE tags (
+ id INTEGER PRIMARY KEY,
+ name TEXT NOT NULL,
+ project_id INTEGER NOT NULL,
+ UNIQUE(project_id, name)
+ )
+ ");
+
+ $pdo->exec("
+ CREATE TABLE task_has_tags (
+ task_id INTEGER NOT NULL,
+ tag_id INTEGER NOT NULL,
+ FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE,
+ FOREIGN KEY(tag_id) REFERENCES tags(id) ON DELETE CASCADE,
+ UNIQUE(tag_id, task_id)
+ )
+ ");
+}
function version_101(PDO $pdo)
{