summaryrefslogtreecommitdiff
path: root/app/Schema/Mysql.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Schema/Mysql.php')
-rw-r--r--app/Schema/Mysql.php54
1 files changed, 53 insertions, 1 deletions
diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php
index 24bc2baf..82dd8428 100644
--- a/app/Schema/Mysql.php
+++ b/app/Schema/Mysql.php
@@ -4,8 +4,60 @@ namespace Schema;
use PDO;
use Core\Security;
+use Model\Link;
-const VERSION = 45;
+const VERSION = 46;
+
+function version_46($pdo)
+{
+ $pdo->exec("CREATE TABLE link
+ (
+ link_id INT NOT NULL AUTO_INCREMENT,
+ project_id INT NOT NULL DEFAULT -1,
+ PRIMARY KEY(link_id)
+ ) ENGINE=InnoDB CHARSET=utf8");
+ $pdo->exec("CREATE TABLE link_label
+ (
+ id INT NOT NULL AUTO_INCREMENT,
+ link_id INT NOT NULL,
+ label TEXT NOT NULL,
+ behaviour INT DEFAULT 2,
+ PRIMARY KEY(id),
+ FOREIGN KEY(link_id) REFERENCES link(link_id) ON DELETE CASCADE
+ ) ENGINE=InnoDB CHARSET=utf8");
+ $pdo->exec("CREATE TABLE task_has_links
+ (
+ id INT NOT NULL AUTO_INCREMENT,
+ link_label_id INT NOT NULL,
+ task_id INT NOT NULL,
+ task_inverse_id INT NOT NULL,
+ PRIMARY KEY(id),
+ FOREIGN KEY(link_label_id) REFERENCES link_label(id) ON DELETE CASCADE,
+ FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE,
+ FOREIGN KEY(task_inverse_id) REFERENCES tasks(id) ON DELETE CASCADE
+ ) ENGINE=InnoDB CHARSET=utf8");
+ $pdo->exec("CREATE INDEX task_has_links_task_index ON task_has_links(task_id)");
+ $pdo->exec("CREATE UNIQUE INDEX task_has_links_unique ON task_has_links(link_label_id, task_id, task_inverse_id)");
+ $rq = $pdo->prepare('INSERT INTO link (project_id) VALUES (?)');
+ $rq->execute(array(-1));
+ $rq->execute(array(-1));
+ $rq->execute(array(-1));
+ $rq->execute(array(-1));
+ $rq->execute(array(-1));
+ $rq->execute(array(-1));
+ $rq = $pdo->prepare('INSERT INTO link_label (link_id, label, behaviour) VALUES (?, ?, ?)');
+ $rq->execute(array(1, t('relates to'), Link::BEHAVIOUR_BOTH));
+ $rq->execute(array(2, t('blocks'), Link::BEHAVIOUR_LEFT2RIGTH));
+ $rq->execute(array(2, t('is blocked by'), Link::BEHAVIOUR_RIGHT2LEFT));
+ $rq->execute(array(3, t('duplicates'), Link::BEHAVIOUR_LEFT2RIGTH));
+ $rq->execute(array(3, t('is duplicated by'), Link::BEHAVIOUR_RIGHT2LEFT));
+ $rq->execute(array(4, t('is a child of'), Link::BEHAVIOUR_LEFT2RIGTH));
+ $rq->execute(array(4, t('is a parent of'), Link::BEHAVIOUR_RIGHT2LEFT));
+ $rq->execute(array(5, t('targets milestone'), Link::BEHAVIOUR_LEFT2RIGTH));
+ $rq->execute(array(5, t('is a milestone of'), Link::BEHAVIOUR_RIGHT2LEFT));
+ $rq->execute(array(6, t('fixes'), Link::BEHAVIOUR_LEFT2RIGTH));
+ $rq->execute(array(6, t('is fixed by'), Link::BEHAVIOUR_RIGHT2LEFT));
+}
function version_45($pdo)
{