06/03 Optimize app

This commit is contained in:
2026-06-03 16:22:02 -04:00
parent ec1c0fc7c1
commit eb85e70793
16 changed files with 406 additions and 5 deletions
+19
View File
@@ -24,6 +24,20 @@ COLUMNS = [
"DATETIME NULL DEFAULT NULL"),
]
CREATE_TABLES = [
"""
CREATE TABLE IF NOT EXISTS audit_logs (
id INT AUTO_INCREMENT PRIMARY KEY,
timestamp DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
action VARCHAR(64) NOT NULL,
description VARCHAR(255),
ip_address VARCHAR(45),
INDEX ix_audit_logs_timestamp (timestamp),
INDEX ix_audit_logs_action (action)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
"""
]
with app.app_context():
with db.engine.connect() as conn:
for table, column, definition in COLUMNS:
@@ -42,4 +56,9 @@ with app.app_context():
conn.commit()
print(f" Added {table}.{column}.")
for sql in CREATE_TABLES:
conn.execute(db.text(sql))
conn.commit()
print(" Created audit_logs table (or already exists).")
print("Done.")