CREATE TABLE IF NOT EXISTS access_logs (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  occurred_at TEXT NOT NULL,
  user_upn TEXT NOT NULL,
  action TEXT NOT NULL,
  method TEXT NOT NULL,
  path TEXT NOT NULL,
  status_code INTEGER,
  share_id INTEGER,
  details TEXT
);

CREATE INDEX IF NOT EXISTS idx_access_logs_occurred_at ON access_logs (occurred_at);
CREATE INDEX IF NOT EXISTS idx_access_logs_user ON access_logs (user_upn);
CREATE INDEX IF NOT EXISTS idx_access_logs_action ON access_logs (action);
