← story.propek
STORY 9.25
Fix 500 + Purge Base + Modo Tráfego
PENDING
ACCEPTANCE CRITERIA (8/12)
Cada query no `ficha360.ts` envolvida em try/catch individual — tabela ausente retorna array vazio, não 500
Criar migration para tabela `deals` (`id`, `customer_id`, `conversation_id`, `current_stage`, `deal_value`, `status`, `created_at`, `updated_at`)
Criar tabela `follow_ups_crm` com schema correto (`id`, `customer_id`, `deal_id`, `assigned_to`, `follow_up_type`, `notes`, `due_at`, `status`, `created_at`, `updated_at`)
`GET /api/crm/ficha360/:customerId` retorna 200 para qualquer customer válido
Migration SQL que limpa TODAS as tabelas de dados de clientes: `customers`, `conversations`, `messages`, `orders`, `lead_scores`, `nps_responses`, `follow_ups`, `attendant_notes`, `leads`, `handoff_locks`, `shipments`, `alias_suggestions`, `bot_learnings`
Estrutura das tabelas intacta — apenas DELETE, sem DROP
Sequences resetadas com `RESTART IDENTITY`
Migration idempotente e segura (não falha se tabela não existir)
CRM carrega `/clientes` sem erros (lista vazia esperada)
Clicar em qualquer futuro cliente abre Ficha 360 sem 500
TypeScript compila sem erros (`npx tsc --noEmit`)
Todas as conversas e mensagens antigas removidas
TIMELINE
30/03/2026
chore: CRM v2 session — Story 9.25 CRM reset, cyber-chief sync, state files [Epic 9]
ba1660a
30/03/2026
feat: M3 Knowledge Integration — full extraction, DS token refactor, Epic 17 complete [Epic 17] [Story 6.1-sales-intelligence-bot]
e3e9ff7