CREATE TABLE IF NOT EXISTS reaction_logs (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  reaction_id INTEGER NOT NULL,
  trigger_event_id INTEGER NOT NULL,
  projection_def TEXT NOT NULL,
  old_value TEXT,
  new_value TEXT,
  action TEXT NOT NULL,
  status TEXT NOT NULL,
  handler_output TEXT,
  duration_ms INTEGER,
  created_at INTEGER NOT NULL DEFAULT (unixepoch() * 1000)
);
CREATE INDEX IF NOT EXISTS idx_rlog_reaction ON reaction_logs(reaction_id);
CREATE INDEX IF NOT EXISTS idx_rlog_event ON reaction_logs(trigger_event_id);
