137 lines
3.5 KiB
Plaintext
137 lines
3.5 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
output = "../../src/generated/tenant"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "mysql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
enum Role {
|
|
ADMIN
|
|
MANAGER
|
|
OPERATOR
|
|
}
|
|
|
|
enum SimulationStatus {
|
|
DRAFT
|
|
CALCULATED
|
|
ARCHIVED
|
|
}
|
|
|
|
enum ImportJobStatus {
|
|
PENDING
|
|
PROCESSING
|
|
DONE
|
|
FAILED
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid())
|
|
name String
|
|
email String @unique
|
|
passwordHash String
|
|
issuedPassword String?
|
|
role Role @default(OPERATOR)
|
|
googleId String? @unique
|
|
githubId String? @unique
|
|
totpSecret String?
|
|
totpEnabled Boolean @default(false)
|
|
lastLoginAt DateTime?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
refreshTokens RefreshToken[]
|
|
auditLogs AuditLog[]
|
|
}
|
|
|
|
model RefreshToken {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
hashed String
|
|
expiresAt DateTime
|
|
revokedAt DateTime?
|
|
createdAt DateTime @default(now())
|
|
|
|
@@index([userId])
|
|
}
|
|
|
|
model AuditLog {
|
|
id String @id @default(uuid())
|
|
userId String?
|
|
user User? @relation(fields: [userId], references: [id], onDelete: SetNull)
|
|
action String
|
|
entity String?
|
|
entityId String?
|
|
ip String?
|
|
metadata Json?
|
|
createdAt DateTime @default(now())
|
|
|
|
@@index([createdAt])
|
|
}
|
|
|
|
model Customer {
|
|
id String @id @default(uuid())
|
|
name String
|
|
document String?
|
|
email String?
|
|
phone String?
|
|
city String?
|
|
state String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
simulations FreightSimulation[]
|
|
}
|
|
|
|
model Carrier {
|
|
id String @id @default(uuid())
|
|
name String
|
|
document String?
|
|
email String?
|
|
phone String?
|
|
baseFee Decimal @default(0) @db.Decimal(10, 2)
|
|
pricePerKg Decimal @default(0) @db.Decimal(10, 2)
|
|
pricePerKm Decimal @default(0) @db.Decimal(10, 2)
|
|
adValoremRate Decimal @default(0) @db.Decimal(6, 4)
|
|
active Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model FreightSimulation {
|
|
id String @id @default(uuid())
|
|
originZip String
|
|
destinationZip String
|
|
originLabel String?
|
|
destinationLabel String?
|
|
weightKg Decimal @db.Decimal(10, 3)
|
|
widthCm Decimal @db.Decimal(8, 2)
|
|
heightCm Decimal @db.Decimal(8, 2)
|
|
lengthCm Decimal @db.Decimal(8, 2)
|
|
cargoValue Decimal @db.Decimal(12, 2)
|
|
quotedPrice Decimal? @db.Decimal(12, 2)
|
|
distanceKm Decimal? @db.Decimal(10, 2)
|
|
chargeableKg Decimal? @db.Decimal(10, 3)
|
|
bestCarrierName String?
|
|
quotes Json?
|
|
status SimulationStatus @default(DRAFT)
|
|
customerId String?
|
|
customer Customer? @relation(fields: [customerId], references: [id], onDelete: SetNull)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@index([createdAt])
|
|
}
|
|
|
|
model ImportJob {
|
|
id String @id @default(uuid())
|
|
filename String
|
|
status ImportJobStatus @default(PENDING)
|
|
error String?
|
|
createdAt DateTime @default(now())
|
|
finishedAt DateTime?
|
|
|
|
@@index([createdAt])
|
|
}
|