Files
accounted/supabase/migrations/20260726174500_notification_settings_missing_underlag_enabled.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

30 lines
1.6 KiB
SQL

-- notification_settings: add the missing per-event toggle for 'missing_underlag'.
--
-- 20240101000035 added five per-event toggles (period_locked_enabled,
-- period_year_closed_enabled, invoice_sent_enabled, receipt_extracted_enabled,
-- receipt_matched_enabled). The weekly "saknade underlag" notification shipped
-- later with its notification_log type (20260712090000), its payload builder and
-- its scheduler pass, but its settings column was never created. The
-- push-notifications extension reads and writes it anyway, so PostgREST rejected
-- the whole six-column select with 42703: getSettings() always fell back to
-- defaults and saveSettings() silently wrote nothing, which disabled all six
-- toggles, not just this one.
--
-- notification_settings is user-scoped by design: it has no company_id (see the
-- deliberate omission from the table lists in 20260330130000 and the
-- "User-scoped tables" section of 20260415000000), one row per user, and quiet
-- hours plus category preferences belong to the person rather than the company.
-- This migration does not change that.
--
-- NOT NULL DEFAULT true (the five siblings are nullable with a default): a
-- boolean toggle has no meaningful null state, and on Postgres 11+ adding a
-- NOT NULL column with a constant default does not rewrite the table.
ALTER TABLE public.notification_settings
ADD COLUMN IF NOT EXISTS missing_underlag_enabled boolean NOT NULL DEFAULT true;
COMMENT ON COLUMN public.notification_settings.missing_underlag_enabled IS
'Per-user mute switch for the weekly missing-underlag (saknade underlag) notification.';
NOTIFY pgrst, 'reload schema';