FEAT: Adiciona tabela agenda_contatos e templates de abertura do WhatsApp
This commit is contained in:
parent
cfde2a23c8
commit
a0e9fc120f
36
database/migrations/010_agenda_contatos.sql
Normal file
36
database/migrations/010_agenda_contatos.sql
Normal file
@ -0,0 +1,36 @@
|
||||
-- ============================================================
|
||||
-- Migration 010: Agenda geral de contatos
|
||||
-- Tabela: agenda_contatos
|
||||
-- ============================================================
|
||||
|
||||
CREATE TABLE IF NOT EXISTS agenda_contatos (
|
||||
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
|
||||
);
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF to_regclass('public.customer_contacts') IS NOT NULL THEN
|
||||
INSERT INTO agenda_contatos (
|
||||
chat_id, phone, name, company, note, updated_by_user_id, created_at, updated_at
|
||||
)
|
||||
SELECT chat_id, phone, name, company, note, updated_by_user_id, created_at, updated_at
|
||||
FROM customer_contacts
|
||||
ON CONFLICT (chat_id) DO UPDATE SET
|
||||
phone = EXCLUDED.phone,
|
||||
name = EXCLUDED.name,
|
||||
company = EXCLUDED.company,
|
||||
note = EXCLUDED.note,
|
||||
updated_by_user_id = EXCLUDED.updated_by_user_id,
|
||||
updated_at = EXCLUDED.updated_at;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_agenda_contatos_updated_at
|
||||
ON agenda_contatos (updated_at DESC);
|
||||
19
database/migrations/011_whatsapp_opening_templates.sql
Normal file
19
database/migrations/011_whatsapp_opening_templates.sql
Normal file
@ -0,0 +1,19 @@
|
||||
-- ============================================================
|
||||
-- Migration 011: Templates de abertura ativa do WhatsApp
|
||||
-- Tabela: whatsapp_templates
|
||||
-- ============================================================
|
||||
|
||||
INSERT INTO whatsapp_templates (name, content) VALUES
|
||||
('abertura_atendimento_padrao', 'Ola, {nome}. Tudo bem? Estamos entrando em contato pelo atendimento. Podemos seguir por aqui?'),
|
||||
('abertura_retorno_contato', 'Ola, {nome}. Estamos retornando seu contato para dar continuidade ao seu atendimento.'),
|
||||
('abertura_suporte', 'Ola, {nome}. Aqui e do suporte. Estamos entrando em contato para te ajudar com sua solicitacao.'),
|
||||
('abertura_financeiro', 'Ola, {nome}. Aqui e do financeiro. Estamos entrando em contato para tratar de uma informacao importante sobre seu atendimento.'),
|
||||
('abertura_comercial', 'Ola, {nome}. Aqui e do comercial. Estamos entrando em contato para conversar sobre sua solicitacao.'),
|
||||
('abertura_confirmacao_dados', 'Ola, {nome}. Precisamos confirmar alguns dados para seguir com seu atendimento.'),
|
||||
('abertura_contato_agendado', 'Ola, {nome}. Este contato foi combinado anteriormente e estamos disponiveis para seguir.'),
|
||||
('abertura_pos_atendimento', 'Ola, {nome}. Estamos fazendo um acompanhamento sobre seu atendimento recente.'),
|
||||
('abertura_aviso_importante', 'Ola, {nome}. Temos uma informacao importante para compartilhar com voce.'),
|
||||
('abertura_contato_inicial', 'Ola, {nome}. Vamos iniciar seu atendimento por este canal.')
|
||||
ON CONFLICT (name) DO UPDATE SET
|
||||
content = EXCLUDED.content,
|
||||
updated_at = CURRENT_TIMESTAMP;
|
||||
10
database/migrations/012_whatsapp_awaiting_customer_reply.sql
Normal file
10
database/migrations/012_whatsapp_awaiting_customer_reply.sql
Normal file
@ -0,0 +1,10 @@
|
||||
-- ============================================================
|
||||
-- Migration 012: Bloqueio apos abertura ativa do WhatsApp
|
||||
-- Tabela: whatsapp_chat_atribuicoes
|
||||
-- ============================================================
|
||||
|
||||
ALTER TABLE whatsapp_chat_atribuicoes
|
||||
ADD COLUMN IF NOT EXISTS awaiting_customer_reply BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_whatsapp_atribuicoes_awaiting_customer_reply
|
||||
ON whatsapp_chat_atribuicoes (awaiting_customer_reply, status);
|
||||
Loading…
Reference in New Issue
Block a user