fix(migration): add WHERE org_id IS NOT NULL to SLA policy inserts to prevent crash on bots with no org
All checks were successful
BotServer CI / build (push) Successful in 2m12s
All checks were successful
BotServer CI / build (push) Successful in 2m12s
This commit is contained in:
parent
622f1222dc
commit
9641842e8d
1 changed files with 4 additions and 4 deletions
|
|
@ -38,19 +38,19 @@ CREATE TABLE IF NOT EXISTS attendance_sla_events (
|
|||
-- 4. Insert default SLA policies
|
||||
INSERT INTO attendance_sla_policies (org_id, bot_id, name, channel, priority, first_response_minutes, resolution_minutes)
|
||||
SELECT DISTINCT org_id, id as bot_id, 'Default - Urgent', NULL, 'urgent', 5, 60
|
||||
FROM bots ON CONFLICT DO NOTHING;
|
||||
FROM bots WHERE org_id IS NOT NULL ON CONFLICT DO NOTHING;
|
||||
|
||||
INSERT INTO attendance_sla_policies (org_id, bot_id, name, channel, priority, first_response_minutes, resolution_minutes)
|
||||
SELECT DISTINCT org_id, id as bot_id, 'Default - High', NULL, 'high', 15, 240
|
||||
FROM bots ON CONFLICT DO NOTHING;
|
||||
FROM bots WHERE org_id IS NOT NULL ON CONFLICT DO NOTHING;
|
||||
|
||||
INSERT INTO attendance_sla_policies (org_id, bot_id, name, channel, priority, first_response_minutes, resolution_minutes)
|
||||
SELECT DISTINCT org_id, id as bot_id, 'Default - Normal', NULL, 'normal', 30, 480
|
||||
FROM bots ON CONFLICT DO NOTHING;
|
||||
FROM bots WHERE org_id IS NOT NULL ON CONFLICT DO NOTHING;
|
||||
|
||||
INSERT INTO attendance_sla_policies (org_id, bot_id, name, channel, priority, first_response_minutes, resolution_minutes)
|
||||
SELECT DISTINCT org_id, id as bot_id, 'Default - Low', NULL, 'low', 60, 1440
|
||||
FROM bots ON CONFLICT DO NOTHING;
|
||||
FROM bots WHERE org_id IS NOT NULL ON CONFLICT DO NOTHING;
|
||||
|
||||
-- 5. Create legacy compat views for leads/opportunities (from crm-sales.md)
|
||||
CREATE OR REPLACE VIEW crm_leads_compat AS
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue