feat: add generated code
This commit is contained in:
206
backend/prisma/schema.prisma
Normal file
206
backend/prisma/schema.prisma
Normal file
@@ -0,0 +1,206 @@
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
enum EquipmentStatus {
|
||||
Active
|
||||
Repair
|
||||
Reserve
|
||||
WriteOff
|
||||
}
|
||||
|
||||
enum RepairOrderStatus {
|
||||
Draft
|
||||
Approved
|
||||
InWork
|
||||
Done
|
||||
Cancelled
|
||||
}
|
||||
|
||||
enum RepairKind {
|
||||
TO
|
||||
TR
|
||||
TRE
|
||||
KR
|
||||
AR
|
||||
MP
|
||||
}
|
||||
|
||||
enum LaborOperation {
|
||||
Manual
|
||||
MachineManual
|
||||
Machine
|
||||
}
|
||||
|
||||
enum EnumPeriodicityTO {
|
||||
Ежедневное
|
||||
Еженедельное
|
||||
Ежемесячное
|
||||
Полугодовое
|
||||
Годовое
|
||||
}
|
||||
|
||||
enum Role {
|
||||
Исполнитель
|
||||
Подписант
|
||||
Пользователь
|
||||
}
|
||||
|
||||
enum CategoryPart {
|
||||
Расходник
|
||||
Запчасть
|
||||
Инструмент
|
||||
Спецодежда
|
||||
}
|
||||
|
||||
enum EquipmentType {
|
||||
Производственное
|
||||
Энергетическое
|
||||
Насосное
|
||||
Компрессорное
|
||||
}
|
||||
|
||||
model Equipment {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
serialNumber String
|
||||
inventoryNumber String @unique
|
||||
equipmentType EquipmentType
|
||||
dateOfInspection DateTime? @db.Date
|
||||
periodicityTO EnumPeriodicityTO
|
||||
location String?
|
||||
status EquipmentStatus
|
||||
commissionedAt DateTime? @db.Date
|
||||
totalEngineHours Decimal? @db.Decimal(10, 2)
|
||||
engineHoursSinceLastRepair Decimal? @db.Decimal(10, 2)
|
||||
lastRepairAt DateTime? @db.Date
|
||||
notes String?
|
||||
|
||||
// Relations
|
||||
repairOrders RepairOrder[]
|
||||
statusChanges ChangeEquipmentStatus[]
|
||||
consumptionRegistrations ConsumptionRegistration[]
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model Employee {
|
||||
code String @id
|
||||
fullName String
|
||||
role Role
|
||||
position String
|
||||
price Float?
|
||||
phoneNumber String?
|
||||
|
||||
// Self-referencing relation for boss-subordinate
|
||||
bossCode String?
|
||||
boss Employee? @relation("BossSubordinates", fields: [bossCode], references: [code])
|
||||
subordinates Employee[] @relation("BossSubordinates")
|
||||
|
||||
// Relations
|
||||
confirmationDocuments ConfirmationDocument[]
|
||||
categoryResources CategoryResource[]
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model Part {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
categories CategoryPart?
|
||||
price Float?
|
||||
description String?
|
||||
serialNumber String?
|
||||
|
||||
// Relations
|
||||
categoryResources CategoryResource[]
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model CategoryResource {
|
||||
id String @id @default(uuid())
|
||||
|
||||
// Relations
|
||||
partId String?
|
||||
part Part? @relation(fields: [partId], references: [id])
|
||||
employeeCode String?
|
||||
employee Employee? @relation(fields: [employeeCode], references: [code])
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model RepairOrder {
|
||||
id String @id @default(uuid())
|
||||
number String @unique
|
||||
date DateTime @db.Date
|
||||
equipmentId String
|
||||
equipment Equipment @relation(fields: [equipmentId], references: [id])
|
||||
repairKind RepairKind
|
||||
status RepairOrderStatus @default(Draft)
|
||||
plannedAt DateTime @db.Date
|
||||
startedAt DateTime? @db.Date
|
||||
completedAt DateTime? @db.Date
|
||||
contractor String?
|
||||
engineHoursAtRepair Decimal? @db.Decimal(10, 2)
|
||||
description String?
|
||||
notes String?
|
||||
confirmed Boolean @default(false)
|
||||
|
||||
// Relations
|
||||
confirmationDocuments ConfirmationDocument[]
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model ChangeEquipmentStatus {
|
||||
id String @id @default(uuid())
|
||||
equipmentId String
|
||||
equipment Equipment @relation(fields: [equipmentId], references: [id])
|
||||
newStatus EquipmentStatus
|
||||
number String?
|
||||
comment String?
|
||||
date DateTime @db.Date
|
||||
responsible String
|
||||
document String? // Store file path or reference
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model ConfirmationDocument {
|
||||
id String @id @default(uuid())
|
||||
number String?
|
||||
date DateTime @db.Date
|
||||
managerCode String
|
||||
manager Employee @relation(fields: [managerCode], references: [code])
|
||||
repairOrderId String
|
||||
repairOrder RepairOrder @relation(fields: [repairOrderId], references: [id])
|
||||
confirmed Boolean
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model ConsumptionRegistration {
|
||||
id String @id @default(uuid())
|
||||
number String?
|
||||
date DateTime @db.Date
|
||||
equipmentId String
|
||||
equipment Equipment @relation(fields: [equipmentId], references: [id])
|
||||
totalEngineHours Decimal? @db.Decimal(10, 2)
|
||||
fuelConsumption Decimal? @db.Decimal(10, 2)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
Reference in New Issue
Block a user