Compare commits
No commits in common. "a0e9fc120f48ad29e89b750dada1fded97a33818" and "ba88d9cf0ba658319080f598b8cc1f55e230f431" have entirely different histories.
a0e9fc120f
...
ba88d9cf0b
@ -1,14 +0,0 @@
|
|||||||
-- ============================================================
|
|
||||||
-- 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);
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
-- ============================================================
|
|
||||||
-- 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);
|
|
||||||
@ -1,36 +0,0 @@
|
|||||||
-- ============================================================
|
|
||||||
-- 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);
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
-- ============================================================
|
|
||||||
-- 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;
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
-- ============================================================
|
|
||||||
-- 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