-- Migration: Tower Log narrative event feed (#7)
-- Adds the tower_log table that stores prose narrative entries about
-- Workshop activity, generated by Haiku on key events.

CREATE TABLE IF NOT EXISTS tower_log (
  id          TEXT PRIMARY KEY,
  narrative   TEXT NOT NULL,
  event_type  TEXT NOT NULL,
  agent_id    TEXT,
  job_id      TEXT,
  created_at  TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE INDEX IF NOT EXISTS idx_tower_log_created_at
  ON tower_log(created_at DESC);
