summaryrefslogtreecommitdiff
path: root/app/Schema/Postgres.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Schema/Postgres.php')
-rw-r--r--app/Schema/Postgres.php53
1 files changed, 51 insertions, 2 deletions
diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php
index d3fb9fc4..af1f3170 100644
--- a/app/Schema/Postgres.php
+++ b/app/Schema/Postgres.php
@@ -4,8 +4,57 @@ namespace Schema;
use PDO;
use Core\Security;
+use Model\Link;
-const VERSION = 26;
+const VERSION = 27;
+
+function version_27($pdo)
+{
+ $pdo->exec("CREATE TABLE link
+ (
+ link_id SERIAL PRIMARY KEY,
+ project_id INTEGER NOT NULL DEFAULT -1
+ ) ENGINE=InnoDB CHARSET=utf8");
+ $pdo->exec("CREATE TABLE link_label
+ (
+ id SERIAL PRIMARY KEY,
+ link_id INTEGER NOT NULL,
+ label TEXT NOT NULL,
+ behaviour INTEGER NOT NULL DEFAULT 2,
+ FOREIGN KEY(link_id) REFERENCES link(link_id) ON DELETE CASCADE
+ ) ENGINE=InnoDB CHARSET=utf8");
+ $pdo->exec("CREATE TABLE task_has_links
+ (
+ id SERIAL PRIMARY KEY,
+ link_label_id INTEGER NOT NULL,
+ task_id INTEGER NOT NULL,
+ task_inverse_id INTEGER NOT NULL,
+ 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_26($pdo)
{
@@ -66,7 +115,7 @@ function version_24($pdo)
function version_23($pdo)
{
- $pdo->exec('ALTER TABLE columns ADD COLUMN description TEXT');
+ $pdo->exec('ALTER TABLE columns ADD COLUMN description TEXT');
}
function version_22($pdo)