diff --git a/meshchatx/src/backend/database/schema.py b/meshchatx/src/backend/database/schema.py index 0585251..c24982b 100644 --- a/meshchatx/src/backend/database/schema.py +++ b/meshchatx/src/backend/database/schema.py @@ -2,7 +2,7 @@ from .provider import DatabaseProvider class DatabaseSchema: - LATEST_VERSION = 19 + LATEST_VERSION = 20 def __init__(self, provider: DatabaseProvider): self.provider = provider @@ -247,6 +247,18 @@ class DatabaseSchema: updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ) """, + "notifications": """ + CREATE TABLE IF NOT EXISTS notifications ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + type TEXT, + remote_hash TEXT, + title TEXT, + content TEXT, + is_viewed INTEGER DEFAULT 0, + timestamp REAL, + created_at DATETIME DEFAULT CURRENT_TIMESTAMP + ) + """, } for table_name, create_sql in tables.items(): @@ -556,6 +568,26 @@ class DatabaseSchema: "CREATE INDEX IF NOT EXISTS idx_call_history_remote_name ON call_history(remote_identity_name)", ) + if current_version < 20: + self.provider.execute(""" + CREATE TABLE IF NOT EXISTS notifications ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + type TEXT, + remote_hash TEXT, + title TEXT, + content TEXT, + is_viewed INTEGER DEFAULT 0, + timestamp REAL, + created_at DATETIME DEFAULT CURRENT_TIMESTAMP + ) + """) + self.provider.execute( + "CREATE INDEX IF NOT EXISTS idx_notifications_remote_hash ON notifications(remote_hash)", + ) + self.provider.execute( + "CREATE INDEX IF NOT EXISTS idx_notifications_timestamp ON notifications(timestamp)", + ) + # Update version in config self.provider.execute( """