summaryrefslogtreecommitdiff
path: root/app/Schema/Sqlite.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-10-03 12:09:27 -0400
committerFrederic Guillot <fred@kanboard.net>2015-10-03 12:09:27 -0400
commitd67d7c54e65e80d1b484490e42dbecb969aa7686 (patch)
treee62446885fac0d3af5b29d409d8e9a4f6c50940e /app/Schema/Sqlite.php
parentb5a2b8f9f7ac9ef947357acd3981993159d64b52 (diff)
Add web notifications
Diffstat (limited to 'app/Schema/Sqlite.php')
-rw-r--r--app/Schema/Sqlite.php37
1 files changed, 36 insertions, 1 deletions
diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php
index 064d0f3c..633c90a7 100644
--- a/app/Schema/Sqlite.php
+++ b/app/Schema/Sqlite.php
@@ -6,7 +6,42 @@ use Core\Security;
use PDO;
use Model\Link;
-const VERSION = 84;
+const VERSION = 85;
+
+function version_85($pdo)
+{
+ $pdo->exec("
+ CREATE TABLE user_has_unread_notifications (
+ id INTEGER PRIMARY KEY,
+ user_id INTEGER NOT NULL,
+ date_creation INTEGER NOT NULL,
+ event_name TEXT NOT NULL,
+ event_data TEXT NOT NULL,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
+ )
+ ");
+
+ $pdo->exec("
+ CREATE TABLE user_has_notification_types (
+ id INTEGER PRIMARY KEY,
+ user_id INTEGER NOT NULL,
+ notification_type TEXT,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
+ )
+ ");
+
+ $pdo->exec('CREATE UNIQUE INDEX user_has_notification_types_user_idx ON user_has_notification_types(user_id, notification_type)');
+
+ // Migrate people who have notification enabled before
+ $rq = $pdo->prepare('SELECT id FROM users WHERE notifications_enabled=1');
+ $rq->execute();
+ $user_ids = $rq->fetchAll(PDO::FETCH_COLUMN, 0);
+
+ foreach ($user_ids as $user_id) {
+ $rq = $pdo->prepare('INSERT INTO user_has_notification_types (user_id, notification_type) VALUES (?, ?)');
+ $rq->execute(array($user_id, 'email'));
+ }
+}
function version_84($pdo)
{