feat(backend): Lagerbehälter-Umlagerung für Honigchargen (Modul 32)
Neues HoneyBatchRelocation-Modell dokumentiert jede Umlagerung einer Honigcharge zwischen Lagerbehältern (von/nach, Zeitpunkt, Benutzer, Notiz). HoneyBatchesService.relocate() aktualisiert HoneyBatch.storageContainerId transaktional zusammen mit dem Historieneintrag; wirft NotFoundException bei unbekanntem Zielbehälter. Neue Endpunkte: POST /honey-batches/:id/relocate, GET /honey-batches/:id/relocations. honeyBatchInclude liefert jetzt zusätzlich den aktuell zugeordneten storageContainer mit. Unit- und E2E-Tests ergänzt (Mehrfachumlagerung, Historienreihenfolge, 404 bei unbekanntem Behälter). Migration auf Dev- und Test-Datenbank angewendet.
This commit is contained in:
1 parent
fa13543578
commit
59a320ae36
7 files changed
+328
-44
No files matched your search
+28
@@ -0,0 +1,28 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "HoneyBatchRelocation" (
|
||||
"id" TEXT NOT NULL,
|
||||
"honeyBatchId" TEXT NOT NULL,
|
||||
"fromStorageContainerId" TEXT,
|
||||
"toStorageContainerId" TEXT NOT NULL,
|
||||
"userId" TEXT,
|
||||
"notes" TEXT,
|
||||
"relocatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "HoneyBatchRelocation_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "HoneyBatchRelocation_honeyBatchId_relocatedAt_idx" ON "HoneyBatchRelocation"("honeyBatchId", "relocatedAt");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "HoneyBatchRelocation" ADD CONSTRAINT "HoneyBatchRelocation_honeyBatchId_fkey" FOREIGN KEY ("honeyBatchId") REFERENCES "HoneyBatch"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "HoneyBatchRelocation" ADD CONSTRAINT "HoneyBatchRelocation_fromStorageContainerId_fkey" FOREIGN KEY ("fromStorageContainerId") REFERENCES "StorageContainer"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "HoneyBatchRelocation" ADD CONSTRAINT "HoneyBatchRelocation_toStorageContainerId_fkey" FOREIGN KEY ("toStorageContainerId") REFERENCES "StorageContainer"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "HoneyBatchRelocation" ADD CONSTRAINT "HoneyBatchRelocation_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
Reference in new issue
Block a user