Files
accounted/supabase/migrations/20260704100000_deadlines_user_id_nullable.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

16 lines
855 B
SQL

-- Drop NOT NULL on deadlines.user_id.
--
-- The multi-tenant company refactor (20260330130000) moved deadlines to
-- company ownership: company_id column + company-scoped RLS, and the tax
-- deadline generator (lib/tax/deadline-generator.ts) stopped sending user_id.
-- The refactor dropped NOT NULL on user_id for audit_log and company_settings
-- (and later fiscal_periods, narrative_signatures) but missed deadlines —
-- since then every auto-generation insert fails with 23502, and because the
-- generator deletes existing system deadlines before inserting, affected
-- companies lost their tax deadlines entirely.
--
-- user_id stays as an optional "created by" attribution for manually created
-- deadlines (app/api/deadlines/route.ts still sends it). Ownership is
-- company_id.
ALTER TABLE public.deadlines ALTER COLUMN user_id DROP NOT NULL;