Files
coding-starter/migrations/pg/2026-04-17_fix-campaign-recipients-constraint.sql
Joachim Hummel ca0c65352e fix: DSGVO-Findings 5+7+6 — Tenant-Guard, APP_URL-Pflichtcheck, Constraint-Migration
- getTenantId wirft bei fehlendem Header statt silent fallback auf 'default'
- Alle API-Routes fangen den Fehler ab und antworten mit 401
- Worker gibt err() zurück wenn APP_URL nicht konfiguriert ist
- Migration: recipient_has_one Constraint schließt NULL/NULL-Zeilen aus

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-17 16:42:50 +00:00

13 lines
444 B
SQL

-- Verhindert campaign_recipients-Zeilen ohne list_id UND segment_id
-- NOT VALID: läuft ohne Table-Lock, bestehende Zeilen beim nächsten VALIDATE CONSTRAINT prüfen
ALTER TABLE campaign_recipients
DROP CONSTRAINT IF EXISTS recipient_has_one;
ALTER TABLE campaign_recipients
ADD CONSTRAINT recipient_has_one CHECK (
(list_id IS NOT NULL AND segment_id IS NULL)
OR
(segment_id IS NOT NULL AND list_id IS NULL)
) NOT VALID;