110 lines
2.7 KiB
Plaintext
110 lines
2.7 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "sqlite" // oder postgres / mysql …
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
/**
|
|
* ───────────── Bestehende Tabellen ─────────────
|
|
*/
|
|
|
|
model Recognition {
|
|
id Int @id @default(autoincrement())
|
|
license String
|
|
licenseFormatted String?
|
|
country String?
|
|
confidence Int?
|
|
timestampUTC DateTime
|
|
timestampLocal DateTime
|
|
cameraName String?
|
|
classification String?
|
|
direction String?
|
|
directionDegrees Int?
|
|
imageFile String?
|
|
plateFile String?
|
|
createdAt DateTime @default(now())
|
|
brand String?
|
|
model String?
|
|
brandmodelconfidence Int?
|
|
|
|
@@unique([license, timestampUTC])
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
username String @unique
|
|
passwordHash String
|
|
isAdmin Boolean @default(false)
|
|
expiresAt DateTime?
|
|
lastLogin DateTime?
|
|
cameraAccess CameraAccess[]
|
|
notificationRules NotificationRule[] @relation("UserRules")
|
|
}
|
|
|
|
model CameraAccess {
|
|
id Int @id @default(autoincrement())
|
|
user User @relation(fields: [userId], references: [id])
|
|
userId String
|
|
camera String
|
|
from DateTime?
|
|
to DateTime?
|
|
}
|
|
|
|
/**
|
|
* ───────────── Neue Tabellen für Benachrichtigungen ─────────────
|
|
*/
|
|
|
|
model NotificationRule {
|
|
id Int @id @default(autoincrement())
|
|
user User @relation("UserRules", fields: [userId], references: [id])
|
|
userId String
|
|
enabled Boolean @default(true)
|
|
|
|
/**
|
|
* optionale Filter --------------
|
|
*/
|
|
plates String?
|
|
brand String?
|
|
model String?
|
|
camera String?
|
|
timeFrom String?
|
|
timeTo String?
|
|
|
|
/**
|
|
* Empfänger ---------------------
|
|
*/
|
|
recipients NotificationRecipient[] @relation("RuleRecipients")
|
|
|
|
/**
|
|
* Unsubscribe Tokens -------
|
|
*/
|
|
unsubscribeTokens UnsubscribeToken[]
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model NotificationRecipient {
|
|
id Int @id @default(autoincrement())
|
|
ruleId Int
|
|
email String
|
|
|
|
rule NotificationRule @relation("RuleRecipients", fields: [ruleId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model UnsubscribeToken {
|
|
id String @id @default(uuid())
|
|
ruleId Int?
|
|
email String
|
|
token String @unique
|
|
createdAt DateTime @default(now())
|
|
expiresAt DateTime
|
|
|
|
rule NotificationRule? @relation(fields: [ruleId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([ruleId, email])
|
|
}
|