FEAT: Adiciona migrations para config WhatsApp e templates HSM
025: Tabela whatsapp_config com access_token, phone_number_id,
api_version e webhook_token (singleton via UNIQUE INDEX on TRUE)
026: waba_id na whatsapp_config; colunas HSM em whatsapp_templates:
language, meta_template_name, meta_template_id, meta_status,
header_type, header_text, footer_text, buttons (JSONB),
body_variables (JSONB)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-23 09:58:01 -03:00
|
|
|
-- Migration 025: Configuração da integração WhatsApp (Meta API)
|
2026-07-22 10:30:02 -03:00
|
|
|
CREATE TABLE IF NOT EXISTS whatsapp_config (
|
FEAT: Adiciona migrations para config WhatsApp e templates HSM
025: Tabela whatsapp_config com access_token, phone_number_id,
api_version e webhook_token (singleton via UNIQUE INDEX on TRUE)
026: waba_id na whatsapp_config; colunas HSM em whatsapp_templates:
language, meta_template_name, meta_template_id, meta_status,
header_type, header_text, footer_text, buttons (JSONB),
body_variables (JSONB)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-23 09:58:01 -03:00
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
|
access_token TEXT,
|
|
|
|
|
phone_number_id VARCHAR(50),
|
|
|
|
|
api_version VARCHAR(20) NOT NULL DEFAULT 'v25.0',
|
|
|
|
|
webhook_token VARCHAR(255),
|
|
|
|
|
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
|
|
|
|
updated_by INTEGER REFERENCES usuarios(id) ON DELETE SET NULL
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
-- Garante que exista no máximo uma linha de configuração
|
2026-07-22 10:30:02 -03:00
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS whatsapp_config_singleton ON whatsapp_config ((TRUE));
|
FEAT: Adiciona migrations para config WhatsApp e templates HSM
025: Tabela whatsapp_config com access_token, phone_number_id,
api_version e webhook_token (singleton via UNIQUE INDEX on TRUE)
026: waba_id na whatsapp_config; colunas HSM em whatsapp_templates:
language, meta_template_name, meta_template_id, meta_status,
header_type, header_text, footer_text, buttons (JSONB),
body_variables (JSONB)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-23 09:58:01 -03:00
|
|
|
|
2026-07-22 10:30:02 -03:00
|
|
|
-- Linha inicial vazia para facilitar o UPDATE posterior
|
FEAT: Adiciona migrations para config WhatsApp e templates HSM
025: Tabela whatsapp_config com access_token, phone_number_id,
api_version e webhook_token (singleton via UNIQUE INDEX on TRUE)
026: waba_id na whatsapp_config; colunas HSM em whatsapp_templates:
language, meta_template_name, meta_template_id, meta_status,
header_type, header_text, footer_text, buttons (JSONB),
body_variables (JSONB)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-23 09:58:01 -03:00
|
|
|
INSERT INTO whatsapp_config (access_token, phone_number_id, api_version, webhook_token)
|
2026-07-22 10:30:02 -03:00
|
|
|
VALUES (NULL, NULL, 'v25.0', NULL)
|
|
|
|
|
ON CONFLICT DO NOTHING;
|