From 54700c0deed43d1ab55a8814bdb4b400356f84ef Mon Sep 17 00:00:00 2001 From: Sudo-Ivan Date: Thu, 1 Jan 2026 23:36:52 -0600 Subject: [PATCH] feat(database): increment schema version to 20 and add notifications table with relevant indices --- meshchatx/src/backend/database/schema.py | 34 +++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) 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( """