24 lines
982 B
PL/PgSQL
24 lines
982 B
PL/PgSQL
-- R-P11b dashboard re-cut: record when a customer invoice was actually paid.
|
|
-- Without it, revenue by payment date and days-to-payment are not measurable:
|
|
-- `updatedAt` is overwritten by any later edit of the row.
|
|
--
|
|
-- Forward-only migration. Existing rows stay NULL on purpose — invoices marked
|
|
-- paid before this column existed carry no trustworthy payment date, and the
|
|
-- dashboard excludes NULL rows from payment-date reporting rather than dating
|
|
-- them wrongly. The inverse SQL at the end is review guidance for a coordinated
|
|
-- rollback and is never executed automatically.
|
|
|
|
BEGIN;
|
|
|
|
-- AlterTable
|
|
ALTER TABLE "Rechnung" ADD COLUMN "bezahltAm" TIMESTAMP(3);
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "Rechnung_tenantId_bezahltAm_idx" ON "Rechnung"("tenantId", "bezahltAm");
|
|
|
|
COMMIT;
|
|
|
|
-- Inverse SQL (manual rollback guidance, never executed automatically):
|
|
-- DROP INDEX IF EXISTS "Rechnung_tenantId_bezahltAm_idx";
|
|
-- ALTER TABLE "Rechnung" DROP COLUMN IF EXISTS "bezahltAm";
|