Changeset 0.22.8 (#150)
This commit is contained in:
27
server/database/migrations/sqlite/011_notifications.sql
Normal file
27
server/database/migrations/sqlite/011_notifications.sql
Normal file
@@ -0,0 +1,27 @@
|
||||
-- Chat Switchboard — 011 Notifications (SQLite)
|
||||
|
||||
CREATE TABLE IF NOT EXISTS notifications (
|
||||
id TEXT PRIMARY KEY,
|
||||
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
type TEXT NOT NULL,
|
||||
title TEXT NOT NULL,
|
||||
body TEXT DEFAULT '',
|
||||
resource_type TEXT,
|
||||
resource_id TEXT,
|
||||
is_read INTEGER DEFAULT 0,
|
||||
created_at TEXT DEFAULT (datetime('now'))
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_notifications_user_unread ON notifications(user_id, is_read, created_at);
|
||||
CREATE INDEX IF NOT EXISTS idx_notifications_user_created ON notifications(user_id, created_at);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS notification_preferences (
|
||||
id TEXT PRIMARY KEY,
|
||||
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
type TEXT NOT NULL,
|
||||
in_app INTEGER NOT NULL DEFAULT 1,
|
||||
email INTEGER NOT NULL DEFAULT 0,
|
||||
UNIQUE(user_id, type)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_notification_prefs_user ON notification_preferences(user_id);
|
||||
Reference in New Issue
Block a user