phosphat-report-app/prisma/schema.prisma
2025-07-24 12:39:15 +03:00

100 lines
2.8 KiB
Plaintext

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
model Report {
id Int @id @default(autoincrement())
employeeId Int
employee Employee @relation(fields: [employeeId], references: [id])
createdDate DateTime @default(now())
updatedDate DateTime @updatedAt
shift String // 'day' or 'night'
areaId Int
area Area @relation(fields: [areaId], references: [id])
dredgerLocationId Int
dredgerLocation DredgerLocation @relation(fields: [dredgerLocationId], references: [id])
dredgerLineLength Int
reclamationLocationId Int
reclamationLocation ReclamationLocation @relation(fields: [reclamationLocationId], references: [id])
shoreConnection Int
reclamationHeight Json // JSON: { base: int, extra: int }
pipelineLength Json // JSON: { main: int, ext1: int, reserve: int, ext2: int }
stats Json // JSON: { Dozers: int, Exc: int, Loaders: int, Foreman: string, Laborer: int }
timeSheet Json // JSON: Array of timesheet objects
stoppages Json // JSON: Array of stoppage records
notes String?
}
model Area {
id Int @id @default(autoincrement())
name String @unique
reports Report[]
}
model DredgerLocation {
id Int @id @default(autoincrement())
name String @unique
class String // 's', 'd', 'sp'
reports Report[]
}
model ReclamationLocation {
id Int @id @default(autoincrement())
name String @unique
reports Report[]
}
model Employee {
id Int @id @default(autoincrement())
name String
authLevel Int
username String @unique
email String @unique
password String
reports Report[]
passwordResetTokens PasswordResetToken[]
}
model PasswordResetToken {
id Int @id @default(autoincrement())
token String @unique
employeeId Int
employee Employee @relation(fields: [employeeId], references: [id], onDelete: Cascade)
expiresAt DateTime
used Boolean @default(false)
createdAt DateTime @default(now())
}
model Foreman {
id Int @id @default(autoincrement())
name String
}
model Equipment {
id Int @id @default(autoincrement())
category String
model String
number Int
}
model MailSettings {
id Int @id @default(autoincrement())
host String
port Int
secure Boolean @default(false)
username String
password String
fromName String
fromEmail String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}