summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common.php2
-rw-r--r--schemas/mysql.php6
-rw-r--r--schemas/sqlite.php27
3 files changed, 33 insertions, 2 deletions
diff --git a/common.php b/common.php
index 8c64419b..fd19b8ca 100644
--- a/common.php
+++ b/common.php
@@ -6,7 +6,7 @@ require __DIR__.'/core/translator.php';
$registry = new Core\Registry;
-$registry->db_version = 10;
+$registry->db_version = 11;
$registry->db = function() use ($registry) {
require __DIR__.'/vendor/PicoDb/Database.php';
diff --git a/schemas/mysql.php b/schemas/mysql.php
index 3b9cc014..cdd497e3 100644
--- a/schemas/mysql.php
+++ b/schemas/mysql.php
@@ -2,6 +2,10 @@
namespace Schema;
+function version_11($pdo)
+{
+}
+
function version_10($pdo)
{
}
@@ -125,7 +129,7 @@ function version_1($pdo)
comment TEXT,
PRIMARY KEY (id),
FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE,
- FOREIGN KEY(user_id) REFERENCES tasks(id) ON DELETE CASCADE
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
) ENGINE=InnoDB CHARSET=utf8
");
diff --git a/schemas/sqlite.php b/schemas/sqlite.php
index 8e5698f5..26ae09f7 100644
--- a/schemas/sqlite.php
+++ b/schemas/sqlite.php
@@ -2,6 +2,33 @@
namespace Schema;
+function version_11($pdo)
+{
+ $pdo->exec(
+ 'ALTER TABLE comments RENAME TO comments_bak'
+ );
+
+ $pdo->exec(
+ 'CREATE TABLE comments (
+ id INTEGER PRIMARY KEY,
+ task_id INTEGER,
+ user_id INTEGER,
+ date INTEGER,
+ comment TEXT,
+ FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
+ )'
+ );
+
+ $pdo->exec(
+ 'INSERT INTO comments SELECT * FROM comments_bak'
+ );
+
+ $pdo->exec(
+ 'DROP TABLE comments_bak'
+ );
+}
+
function version_10($pdo)
{
$pdo->exec(