CREATE TABLE IF NOT EXISTS request_logs (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  method TEXT NOT NULL,
  path TEXT NOT NULL,
  api_key_id INTEGER,
  api_key_name TEXT,
  status_code INTEGER NOT NULL,
  error TEXT,
  duration_ms INTEGER,
  created_at INTEGER NOT NULL DEFAULT (unixepoch() * 1000)
);
CREATE INDEX IF NOT EXISTS idx_reqlog_key ON request_logs(api_key_id);
CREATE INDEX IF NOT EXISTS idx_reqlog_created ON request_logs(created_at);
