summaryrefslogtreecommitdiff
path: root/app/Schema
diff options
context:
space:
mode:
Diffstat (limited to 'app/Schema')
-rw-r--r--app/Schema/Mysql.php54
-rw-r--r--app/Schema/Postgres.php54
-rw-r--r--app/Schema/Sqlite.php37
3 files changed, 142 insertions, 3 deletions
diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php
index 9b202a69..9ab12a1a 100644
--- a/app/Schema/Mysql.php
+++ b/app/Schema/Mysql.php
@@ -4,7 +4,59 @@ namespace Schema;
use Core\Security;
-const VERSION = 24;
+const VERSION = 25;
+
+function version_25($pdo)
+{
+ $pdo->exec("
+ CREATE TABLE task_has_events (
+ id INT NOT NULL AUTO_INCREMENT,
+ date_creation INT NOT NULL,
+ event_name TEXT NOT NULL,
+ creator_id INT,
+ project_id INT,
+ task_id INT,
+ data TEXT,
+ FOREIGN KEY(creator_id) REFERENCES users(id) ON DELETE CASCADE,
+ FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
+ FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
+ );
+ ");
+
+ $pdo->exec("
+ CREATE TABLE subtask_has_events (
+ id INT NOT NULL AUTO_INCREMENT,
+ date_creation INT NOT NULL,
+ event_name TEXT NOT NULL,
+ creator_id INT,
+ project_id INT,
+ subtask_id INT,
+ task_id INT,
+ data TEXT,
+ FOREIGN KEY(creator_id) REFERENCES users(id) ON DELETE CASCADE,
+ FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
+ FOREIGN KEY(subtask_id) REFERENCES task_has_subtasks(id) ON DELETE CASCADE,
+ FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
+ );
+ ");
+
+ $pdo->exec("
+ CREATE TABLE comment_has_events (
+ id INT NOT NULL AUTO_INCREMENT,
+ date_creation INT NOT NULL,
+ event_name TEXT NOT NULL,
+ creator_id INT,
+ project_id INT,
+ comment_id INT,
+ task_id INT,
+ data TEXT,
+ FOREIGN KEY(creator_id) REFERENCES users(id) ON DELETE CASCADE,
+ FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
+ FOREIGN KEY(comment_id) REFERENCES comments(id) ON DELETE CASCADE,
+ FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
+ );
+ ");
+}
function version_24($pdo)
{
diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php
index 99774a55..b58b9bb3 100644
--- a/app/Schema/Postgres.php
+++ b/app/Schema/Postgres.php
@@ -4,7 +4,59 @@ namespace Schema;
use Core\Security;
-const VERSION = 5;
+const VERSION = 6;
+
+function version_6($pdo)
+{
+ $pdo->exec("
+ CREATE TABLE task_has_events (
+ id SERIAL PRIMARY KEY,
+ date_creation INTEGER NOT NULL,
+ event_name TEXT NOT NULL,
+ creator_id INTEGER,
+ project_id INTEGER,
+ task_id INTEGER,
+ data TEXT,
+ FOREIGN KEY(creator_id) REFERENCES users(id) ON DELETE CASCADE,
+ FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
+ FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
+ );
+ ");
+
+ $pdo->exec("
+ CREATE TABLE subtask_has_events (
+ id SERIAL PRIMARY KEY,
+ date_creation INTEGER NOT NULL,
+ event_name TEXT NOT NULL,
+ creator_id INTEGER,
+ project_id INTEGER,
+ subtask_id INTEGER,
+ task_id INTEGER,
+ data TEXT,
+ FOREIGN KEY(creator_id) REFERENCES users(id) ON DELETE CASCADE,
+ FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
+ FOREIGN KEY(subtask_id) REFERENCES task_has_subtasks(id) ON DELETE CASCADE,
+ FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
+ );
+ ");
+
+ $pdo->exec("
+ CREATE TABLE comment_has_events (
+ id SERIAL PRIMARY KEY,
+ date_creation INTEGER NOT NULL,
+ event_name TEXT NOT NULL,
+ creator_id INTEGER,
+ project_id INTEGER,
+ comment_id INTEGER,
+ task_id INTEGER,
+ data TEXT,
+ FOREIGN KEY(creator_id) REFERENCES users(id) ON DELETE CASCADE,
+ FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
+ FOREIGN KEY(comment_id) REFERENCES comments(id) ON DELETE CASCADE,
+ FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
+ );
+ ");
+}
function version_5($pdo)
{
diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php
index e18d35e9..ecd62c97 100644
--- a/app/Schema/Sqlite.php
+++ b/app/Schema/Sqlite.php
@@ -11,13 +11,48 @@ function version_25($pdo)
$pdo->exec("
CREATE TABLE task_has_events (
id INTEGER PRIMARY KEY,
- date_creation INTEGER,
+ date_creation INTEGER NOT NULL,
+ event_name TEXT NOT NULL,
+ creator_id INTEGER,
+ project_id INTEGER,
+ task_id INTEGER,
+ data TEXT,
+ FOREIGN KEY(creator_id) REFERENCES users(id) ON DELETE CASCADE,
+ FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
+ FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
+ );
+ ");
+
+ $pdo->exec("
+ CREATE TABLE subtask_has_events (
+ id INTEGER PRIMARY KEY,
+ date_creation INTEGER NOT NULL,
+ event_name TEXT NOT NULL,
+ creator_id INTEGER,
+ project_id INTEGER,
+ subtask_id INTEGER,
+ task_id INTEGER,
+ data TEXT,
+ FOREIGN KEY(creator_id) REFERENCES users(id) ON DELETE CASCADE,
+ FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
+ FOREIGN KEY(subtask_id) REFERENCES task_has_subtasks(id) ON DELETE CASCADE,
+ FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
+ );
+ ");
+
+ $pdo->exec("
+ CREATE TABLE comment_has_events (
+ id INTEGER PRIMARY KEY,
+ date_creation INTEGER NOT NULL,
event_name TEXT NOT NULL,
creator_id INTEGER,
project_id INTEGER,
+ comment_id INTEGER,
task_id INTEGER,
+ data TEXT,
FOREIGN KEY(creator_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
+ FOREIGN KEY(comment_id) REFERENCES comments(id) ON DELETE CASCADE,
FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
);
");