From 074056352de98fc567b4d13184c72887c75625d0 Mon Sep 17 00:00:00 2001
From: Frédéric Guillot <fred@kanboard.net>
Date: Sun, 12 Oct 2014 21:38:56 -0400
Subject: Project activity refactoring and listeners improvements

---
 app/Schema/Mysql.php    | 27 +++++++++++++++++++++++++--
 app/Schema/Postgres.php | 24 +++++++++++++++++++++++-
 app/Schema/Sqlite.php   | 24 +++++++++++++++++++++++-
 3 files changed, 71 insertions(+), 4 deletions(-)

(limited to 'app/Schema')

diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php
index 7a0b2cd1..05bef8cd 100644
--- a/app/Schema/Mysql.php
+++ b/app/Schema/Mysql.php
@@ -5,7 +5,30 @@ namespace Schema;
 use PDO;
 use Core\Security;
 
-const VERSION = 32;
+const VERSION = 33;
+
+function version_33($pdo)
+{
+    $pdo->exec("
+        CREATE TABLE project_activities (
+            id INT NOT NULL AUTO_INCREMENT,
+            date_creation INT NOT NULL,
+            event_name VARCHAR(50) NOT NULL,
+            creator_id INT,
+            project_id INT,
+            task_id INT,
+            data TEXT,
+            PRIMARY KEY(id),
+            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
+        ) ENGINE=InnoDB CHARSET=utf8
+    ");
+
+    $pdo->exec('DROP TABLE task_has_events');
+    $pdo->exec('DROP TABLE comment_has_events');
+    $pdo->exec('DROP TABLE subtask_has_events');
+}
 
 function version_32($pdo)
 {
@@ -355,7 +378,7 @@ function version_1($pdo)
             id INT NOT NULL AUTO_INCREMENT,
             task_id INT,
             user_id INT,
-            date INT,
+            `date` INT,
             comment TEXT,
             PRIMARY KEY (id),
             FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE,
diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php
index e42e8e72..8aaff259 100644
--- a/app/Schema/Postgres.php
+++ b/app/Schema/Postgres.php
@@ -5,7 +5,29 @@ namespace Schema;
 use PDO;
 use Core\Security;
 
-const VERSION = 13;
+const VERSION = 14;
+
+function version_14($pdo)
+{
+    $pdo->exec("
+        CREATE TABLE project_activities (
+            id SERIAL PRIMARY KEY,
+            date_creation INTEGER NOT NULL,
+            event_name VARCHAR(50) 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('DROP TABLE task_has_events');
+    $pdo->exec('DROP TABLE comment_has_events');
+    $pdo->exec('DROP TABLE subtask_has_events');
+}
 
 function version_13($pdo)
 {
diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php
index f290c824..3c220f8c 100644
--- a/app/Schema/Sqlite.php
+++ b/app/Schema/Sqlite.php
@@ -5,7 +5,29 @@ namespace Schema;
 use Core\Security;
 use PDO;
 
-const VERSION = 32;
+const VERSION = 33;
+
+function version_33($pdo)
+{
+    $pdo->exec("
+        CREATE TABLE project_activities (
+            id INTEGER 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('DROP TABLE task_has_events');
+    $pdo->exec('DROP TABLE comment_has_events');
+    $pdo->exec('DROP TABLE subtask_has_events');
+}
 
 function version_32($pdo)
 {
-- 
cgit v1.2.3