-- Migration: Session conversation history (#38/#39)
-- Stores user/assistant message pairs for context injection into the work model.

CREATE TABLE IF NOT EXISTS session_messages (
  id          SERIAL PRIMARY KEY,
  session_id  TEXT NOT NULL REFERENCES sessions(id),
  role        TEXT NOT NULL,
  content     TEXT NOT NULL,
  token_count INTEGER,
  created_at  TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE INDEX idx_session_messages_session_id ON session_messages(session_id);
