-- Migration: Session messages for conversation history
-- Stores user/assistant message pairs produced during session requests.

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,
  session_request_id TEXT,
  created_at         TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE INDEX idx_session_messages_session_id ON session_messages(session_id);
