Files
accounted/supabase/migrations/20260515180000_webhook_deliveries_retention.sql
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

34 lines
1.5 KiB
SQL

-- Migration: webhook_deliveries_retention
--
-- Originally added in PR #496 round 1 to ALTER the webhook_deliveries.webhook_id
-- FK from ON DELETE CASCADE to ON DELETE SET NULL (BFNAR 2013:2 kap 8 §
-- behandlingshistorik + BFL 7 kap retention).
--
-- In round 3 the FK declaration was folded directly into migration
-- 20260515170000 (clean schema state for fresh installs). This file is
-- retained for migration-history continuity — Supabase preview branches
-- track the set of applied remote migrations and fail reconciliation if
-- a previously-applied filename disappears locally.
--
-- The body below is fully idempotent:
-- - On a fresh install: 170000 creates the FK with SET NULL; this
-- migration's ALTER is a no-op (DROP IF EXISTS + ADD with the same
-- constraint shape).
-- - On a preview branch that applied the original 170000 (CASCADE) +
-- this 180000 (the original ALTER): the column is already nullable
-- and the FK is already SET NULL; ALTER is a no-op.
-- - Idempotent retro-application is intentional so neither path
-- diverges from the canonical post-migration schema state.
ALTER TABLE public.webhook_deliveries
ALTER COLUMN webhook_id DROP NOT NULL;
ALTER TABLE public.webhook_deliveries
DROP CONSTRAINT IF EXISTS webhook_deliveries_webhook_id_fkey;
ALTER TABLE public.webhook_deliveries
ADD CONSTRAINT webhook_deliveries_webhook_id_fkey
FOREIGN KEY (webhook_id) REFERENCES public.webhooks(id) ON DELETE SET NULL;
NOTIFY pgrst, 'reload schema';