feature: Add editable hostname and operating system
Release / Build and Push Docker Image (push) Successful in 4m56s

This commit is contained in:
Keith Solomon
2026-04-14 07:42:39 -05:00
parent 1d9e98872c
commit d10e533793
8 changed files with 192 additions and 7 deletions
+11
View File
@@ -22,9 +22,11 @@ CREATE TABLE IF NOT EXISTS devices (
id INTEGER PRIMARY KEY AUTOINCREMENT,
ip TEXT NOT NULL UNIQUE,
hostname TEXT,
custom_hostname TEXT,
mac TEXT,
vendor TEXT,
os_name TEXT,
custom_os_name TEXT,
first_seen TEXT NOT NULL,
last_seen TEXT NOT NULL,
is_active INTEGER NOT NULL DEFAULT 1,
@@ -61,6 +63,15 @@ def init_db() -> None:
db_file.parent.mkdir(parents=True, exist_ok=True)
with sqlite3.connect(DB_PATH) as conn:
conn.executescript(SCHEMA)
ensure_column(conn, "devices", "custom_hostname", "TEXT")
ensure_column(conn, "devices", "custom_os_name", "TEXT")
def ensure_column(conn: sqlite3.Connection, table: str, column: str, definition: str) -> None:
existing = conn.execute(f"PRAGMA table_info({table})").fetchall()
column_names = {row[1] for row in existing}
if column not in column_names:
conn.execute(f"ALTER TABLE {table} ADD COLUMN {column} {definition}")
@contextmanager