-- Audit log table for tracking user actions. CREATE TABLE audit_log ( id INTEGER PRIMARY KEY, user_id INTEGER, username TEXT NOT NULL, action TEXT NOT NULL, resource_type TEXT NOT NULL, resource_id TEXT, detail TEXT, remote_ip TEXT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP ); CREATE INDEX idx_audit_log_created_at ON audit_log(created_at); CREATE INDEX idx_audit_log_action ON audit_log(action); CREATE INDEX idx_audit_log_resource ON audit_log(resource_type, resource_id);