FEAT: Tabelas de contatos e notas dos agentes

This commit is contained in:
Rafael Alves Lopes 2026-05-19 17:50:08 -03:00
parent ba88d9cf0b
commit cfde2a23c8
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,14 @@
-- ============================================================
-- 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);

View File

@ -0,0 +1,18 @@
-- ============================================================
-- Migration 009: Agenda de contatos dos clientes
-- Tabela: customer_contacts
-- ============================================================
CREATE TABLE IF NOT EXISTS customer_contacts (
chat_id VARCHAR(255) PRIMARY KEY,
phone VARCHAR(80) NOT NULL,
name VARCHAR(255),
company VARCHAR(255),
note TEXT,
updated_by_user_id INTEGER REFERENCES usuarios(id) ON DELETE SET NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX IF NOT EXISTS idx_customer_contacts_updated_at
ON customer_contacts (updated_at DESC);