fix server - agent
This commit is contained in:
@@ -38,6 +38,7 @@ CREATE TABLE IF NOT EXISTS installed_apps (
|
||||
app_id TEXT PRIMARY KEY,
|
||||
app_name TEXT NOT NULL,
|
||||
version TEXT NOT NULL,
|
||||
open_url TEXT,
|
||||
manifest_hash TEXT,
|
||||
status TEXT NOT NULL,
|
||||
installed_at TEXT NOT NULL,
|
||||
@@ -86,6 +87,15 @@ CREATE TABLE IF NOT EXISTS agent_config (
|
||||
"""
|
||||
|
||||
|
||||
def _ensure_column(connection: sqlite3.Connection, table: str, column: str, definition: str) -> None:
|
||||
columns = {
|
||||
row["name"]
|
||||
for row in connection.execute(f"PRAGMA table_info({table})").fetchall()
|
||||
}
|
||||
if column not in columns:
|
||||
connection.execute(f"ALTER TABLE {table} ADD COLUMN {column} {definition}")
|
||||
|
||||
|
||||
def get_connection() -> sqlite3.Connection:
|
||||
connection = sqlite3.connect(settings.db_path, timeout=30)
|
||||
connection.row_factory = sqlite3.Row
|
||||
@@ -99,4 +109,4 @@ def initialize_database() -> None:
|
||||
settings.log_dir.mkdir(parents=True, exist_ok=True)
|
||||
with get_connection() as connection:
|
||||
connection.executescript(SCHEMA)
|
||||
|
||||
_ensure_column(connection, "installed_apps", "open_url", "TEXT")
|
||||
|
||||
Reference in New Issue
Block a user