-- Invoice date: separate from created_at. Lets the user back-date an
-- invoice (typical bookkeeping flow: "April 30 invoice" created
-- whenever in May). created_at stays as the row's insertion timestamp;
-- invoice_date is the user-facing accounting date.
--
-- NULL allowed so old rows don't error; the create form defaults new
-- invoices to the last day of the previous month at creation time
-- (per user direction 2026-05-25).

alter table public.invoices
  add column if not exists invoice_date date;

comment on column public.invoices.invoice_date is
  'User-facing accounting date for the invoice. Distinct from created_at (insertion timestamp). Default at create-time: last day of the previous month.';
