-- ============================================================
-- Migration 008: Notas pessoais dos atendentes
-- Tabela: agent_notes
-- ============================================================

CREATE TABLE IF NOT EXISTS agent_notes (
  id SERIAL PRIMARY KEY,
  user_id INTEGER NOT NULL REFERENCES usuarios(id) ON DELETE CASCADE,
  text TEXT NOT NULL,
  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX IF NOT EXISTS idx_agent_notes_user_created_at
  ON agent_notes (user_id, created_at DESC);
