Mehrere Stichtage pro Zeitraum verwalten
All checks were successful
CI / Build and Deploy (push) Successful in 2m43s

This commit is contained in:
jan
2026-05-12 01:37:28 +02:00
parent 08df13c044
commit 5591d10d96
11 changed files with 790 additions and 88 deletions

View File

@@ -0,0 +1,37 @@
CREATE TABLE "period_cutoffs" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"date" TIMESTAMP(3),
"period_id" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
CONSTRAINT "period_cutoffs_pkey" PRIMARY KEY ("id")
);
CREATE INDEX "period_cutoffs_period_id_idx" ON "period_cutoffs"("period_id");
ALTER TABLE "period_cutoffs"
ADD CONSTRAINT "period_cutoffs_period_id_fkey"
FOREIGN KEY ("period_id") REFERENCES "accounting_periods"("id")
ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "expenses" ADD COLUMN "cutoff_id" TEXT;
INSERT INTO "period_cutoffs" ("id", "name", "date", "period_id", "created_at", "updated_at")
SELECT
'cutoff_' || md5("id"),
COALESCE(NULLIF("cutoff_name", ''), 'Open Air'),
"cutoff_date",
"id",
CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP
FROM "accounting_periods";
UPDATE "expenses"
SET "cutoff_id" = 'cutoff_' || md5("period_id");
ALTER TABLE "expenses"
ADD CONSTRAINT "expenses_cutoff_id_fkey"
FOREIGN KEY ("cutoff_id") REFERENCES "period_cutoffs"("id")
ON DELETE SET NULL ON UPDATE CASCADE;