added contract history

This commit is contained in:
2026-02-08 19:24:37 +01:00
parent ee4f1aacdd
commit e348e86c60
33 changed files with 3200 additions and 743 deletions
@@ -0,0 +1,15 @@
-- CreateTable
CREATE TABLE `ContractHistoryEntry` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`contractId` INTEGER NOT NULL,
`title` VARCHAR(191) NOT NULL,
`description` TEXT NULL,
`isAutomatic` BOOLEAN NOT NULL DEFAULT false,
`createdBy` VARCHAR(191) NOT NULL,
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- AddForeignKey
ALTER TABLE `ContractHistoryEntry` ADD CONSTRAINT `ContractHistoryEntry_contractId_fkey` FOREIGN KEY (`contractId`) REFERENCES `Contract`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
+14
View File
@@ -566,11 +566,25 @@ model Contract {
tasks ContractTask[]
assignedEmails CachedEmail[] // Zugeordnete E-Mails aus dem E-Mail-Client
historyEntries ContractHistoryEntry[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
// ==================== CONTRACT HISTORY ====================
model ContractHistoryEntry {
id Int @id @default(autoincrement())
contractId Int
contract Contract @relation(fields: [contractId], references: [id], onDelete: Cascade)
title String // Kurzbeschreibung (z.B. "Folgevertrag erstellt", "kWh auf 18000 erhöht")
description String? @db.Text // Längere Beschreibung (optional)
isAutomatic Boolean @default(false) // true = automatisch erstellt, false = manuell
createdBy String // E-Mail des Erstellers
createdAt DateTime @default(now())
}
// ==================== CONTRACT TASKS ====================
enum ContractTaskStatus {