primeira versão do e-li-nps construido com IA

This commit is contained in:
Luiz Silva 2025-12-31 11:18:20 -03:00
commit 06950d6e2c
34 changed files with 2524 additions and 0 deletions

31
migrations/001_init.sql Normal file
View file

@ -0,0 +1,31 @@
-- e-li.nps base migration (run once)
CREATE EXTENSION IF NOT EXISTS pgcrypto;
-- Example product table (optional; app auto-creates per product):
-- CREATE TABLE IF NOT EXISTS nps_exemplo (
-- id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
-- inquilino_codigo text NOT NULL,
-- inquilino_nome text NOT NULL,
-- usuario_codigo text,
-- usuario_nome text NOT NULL,
-- usuario_email text,
-- usuario_telefone text,
-- status text NOT NULL CHECK (status IN ('pedido','respondido')),
-- pedido_criado_em timestamptz NOT NULL DEFAULT now(),
-- respondido_em timestamptz NULL,
-- atualizado_em timestamptz NOT NULL DEFAULT now(),
-- nota int NULL CHECK (nota BETWEEN 1 AND 10),
-- justificativa text NULL,
-- valida bool NOT NULL DEFAULT true,
-- origem text NOT NULL DEFAULT 'widget_iframe',
-- user_agent text NULL,
-- ip_real text NULL
-- );
--
-- CREATE INDEX IF NOT EXISTS idx_nps_resp_recente_exemplo
-- ON nps_exemplo (inquilino_codigo, usuario_codigo, respondido_em DESC)
-- WHERE status='respondido' AND valida=true;
--
-- CREATE INDEX IF NOT EXISTS idx_nps_pedido_aberto_exemplo
-- ON nps_exemplo (inquilino_codigo, usuario_codigo, pedido_criado_em DESC)
-- WHERE status='pedido';