Å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.
18 lines
939 B
SQL
18 lines
939 B
SQL
-- Belt-and-suspenders for the nullable invoice_number column.
|
|
-- Invoices in any status that implies they have left the draft stage must carry
|
|
-- a number. ensureInvoiceNumber covers known send paths in application code,
|
|
-- but a future caller could transition status without going through that helper
|
|
-- and silently produce a sent invoice with no löpnummer (ML 17 kap 24§ violation).
|
|
--
|
|
-- 'draft' and 'cancelled' are the only statuses where invoice_number may legally
|
|
-- be NULL — drafts have not been numbered yet, and cancelled-from-draft never
|
|
-- needed one. Cancelled-after-send retains its existing number, so the rule
|
|
-- still holds. Status enum from invoices_status_check:
|
|
-- draft, sent, paid, partially_paid, overdue, cancelled, credited
|
|
|
|
ALTER TABLE public.invoices
|
|
ADD CONSTRAINT invoices_sent_requires_number
|
|
CHECK (status IN ('draft', 'cancelled') OR invoice_number IS NOT NULL);
|
|
|
|
NOTIFY pgrst, 'reload schema';
|