Add RBAC: admin user management, audit log, runtime settings, delete PC

This commit is contained in:
2026-07-16 17:28:04 +07:00
parent c2148f334d
commit d1128f4aa3
16 changed files with 690 additions and 24 deletions
+14
View File
@@ -24,3 +24,17 @@ def get_db():
def create_tables():
Base.metadata.create_all(bind=engine)
def run_migrations():
"""Apply lightweight schema migrations for SQLite."""
from sqlalchemy import inspect, text
insp = inspect(engine)
# AuditLog: add username column if missing
if "audit_log" in insp.get_table_names():
audit_cols = {c["name"] for c in insp.get_columns("audit_log")}
if "username" not in audit_cols:
with engine.connect() as conn:
conn.execute(text("ALTER TABLE audit_log ADD COLUMN username TEXT"))
conn.commit()