Add campaign outreach schema (migration v8)

This commit is contained in:
Gustavo
2026-08-01 10:14:54 -03:00
parent 4f736562f3
commit a7abd3d4d0
2 changed files with 97 additions and 0 deletions
+18
View File
@@ -126,3 +126,21 @@ test('seeds de segments, municipios e geo_cache', () => {
assert.equal(bbox.provider, 'config-legacy');
db.close();
});
test('migracao v8 cria as tabelas de campanha de outreach', () => {
const db = openDb(':memory:');
const tabelas = db.prepare(
`SELECT name FROM sqlite_master WHERE type='table' AND name LIKE 'outreach_%'`
).all().map((r) => r.name);
for (const nome of [
'outreach_campaigns', 'outreach_campaign_variants', 'outreach_campaign_queue',
'outreach_lead_states', 'outreach_stage_events', 'outreach_appointments', 'outreach_opt_out'
]) {
assert.ok(tabelas.includes(nome), `tabela ${nome} deveria existir`);
}
db.prepare(`INSERT INTO outreach_campaigns (nome, produto, segmentos_json) VALUES ('Teste', 'ERP', '["oficinas"]')`).run();
const campanha = db.prepare('SELECT * FROM outreach_campaigns').get();
assert.equal(campanha.status, 'rascunho');
assert.equal(campanha.limite_diario_atual, 10);
db.close();
});