Files
accounted/supabase/migrations/20260712100200_invoice_stripe_payment_link.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

26 lines
1.3 KiB
SQL

-- Stripe payment link automation on invoices.
--
-- stripe_payment_link_id: the plink_... id of the auto-created Stripe Payment
-- Link (NULL for manually pasted links). Presence marks provenance, drives
-- deactivation on credit/paid, and is the deterministic matching key when a
-- checkout.session.completed event points back at the invoice
-- (session.payment_link == this id).
--
-- payment_link_auto: per-invoice opt-out for the automation. When TRUE (the
-- default) and the company has an active Stripe connection, sending the
-- invoice creates a Payment Link and fills payment_link_url. A manually
-- pasted payment_link_url always wins (the hook only fires when the column
-- is NULL). Like payment_link_url itself, neither column is copied to
-- derived documents (credit notes, proforma conversions, recurring copies).
alter table public.invoices
add column if not exists stripe_payment_link_id text,
add column if not exists payment_link_auto boolean not null default true;
comment on column public.invoices.stripe_payment_link_id is
'Stripe Payment Link id (plink_...) when the link was auto-created via the Stripe extension. NULL for manual links.';
comment on column public.invoices.payment_link_auto is
'Create a Stripe Payment Link automatically on send (when connected and payment_link_url is empty).';
NOTIFY pgrst, 'reload schema';