generator client { provider = "prisma-client-js" } datasource db { provider = "postgresql" url = env("DATABASE_URL") } model Province { id String @id @default(uuid()) name String nameEN String createdBy String? createdAt DateTime @default(now()) updateBy String? updatedAt DateTime @updatedAt district District[] branch Branch[] user User[] customerBranch CustomerBranch[] employee Employee[] employeeCheckup EmployeeCheckup[] } model District { id String @id @default(uuid()) name String nameEN String provinceId String province Province @relation(fields: [provinceId], references: [id], onDelete: Cascade) createdBy String? createdAt DateTime @default(now()) updateBy String? updatedAt DateTime @updatedAt subDistrict SubDistrict[] branch Branch[] user User[] customerBranch CustomerBranch[] employee Employee[] } model SubDistrict { id String @id @default(uuid()) name String nameEN String zipCode String district District @relation(fields: [districtId], references: [id], onDelete: Cascade) districtId String createdBy String? createdAt DateTime @default(now()) updateBy String? updatedAt DateTime @updatedAt branch Branch[] user User[] customerBranch CustomerBranch[] employee Employee[] } enum Status { CREATED ACTIVE INACTIVE } model Branch { id String @id @default(uuid()) code String taxNo String name String nameEN String address String addressEN String province Province? @relation(fields: [provinceId], references: [id], onDelete: SetNull) provinceId String? district District? @relation(fields: [districtId], references: [id], onDelete: SetNull) districtId String? subDistrict SubDistrict? @relation(fields: [subDistrictId], references: [id], onDelete: SetNull) subDistrictId String? zipCode String email String telephoneNo String latitude String longitude String isHeadOffice Boolean @default(false) headOffice Branch? @relation(name: "HeadOfficeRelation", fields: [headOfficeId], references: [id]) headOfficeId String? status Status @default(CREATED) createdBy String? createdAt DateTime @default(now()) updateBy String? updatedAt DateTime @updatedAt branch Branch[] @relation(name: "HeadOfficeRelation") contact BranchContact[] user BranchUser[] } model BranchContact { id String @id @default(uuid()) telephoneNo String lineId String branch Branch @relation(fields: [branchId], references: [id], onDelete: Cascade) branchId String createdBy String? createdAt DateTime @default(now()) updateBy String? updatedAt DateTime @updatedAt } model BranchUser { id String @id @default(uuid()) branch Branch @relation(fields: [branchId], references: [id], onDelete: Cascade) branchId String user User @relation(fields: [userId], references: [id], onDelete: Cascade) userId String createdBy String? createdAt DateTime @default(now()) updateBy String? updatedAt DateTime @updatedAt } enum UserType { USER MESSENGER DELEGATE AGENCY } model User { id String @id @default(uuid()) keycloakId String code String? firstName String firstNameEN String lastName String lastNameEN String gender String address String addressEN String province Province? @relation(fields: [provinceId], references: [id], onDelete: SetNull) provinceId String? district District? @relation(fields: [districtId], references: [id], onDelete: SetNull) districtId String? subDistrict SubDistrict? @relation(fields: [subDistrictId], references: [id], onDelete: SetNull) subDistrictId String? zipCode String email String telephoneNo String registrationNo String? startDate DateTime? retireDate DateTime? userType UserType userRole String discountCondition String? licenseNo String? licenseIssueDate DateTime? licenseExpireDate DateTime? sourceNationality String? importNationality String? trainingPlace String? status Status @default(CREATED) createdBy String? createdAt DateTime @default(now()) updateBy String? updatedAt DateTime @updatedAt branch BranchUser[] } enum CustomerType { CORP PERS } model Customer { id String @id @default(uuid()) code String customerType CustomerType customerName String customerNameEN String status Status @default(CREATED) createdBy String? createdAt DateTime @default(now()) updateBy String? updatedAt DateTime @updatedAt branch CustomerBranch[] } model CustomerBranch { id String @id @default(uuid()) branchNo String legalPersonNo String name String nameEN String customer Customer @relation(fields: [customerId], references: [id], onDelete: Cascade) customerId String taxNo String registerName String registerDate DateTime authorizedCapital String address String addressEN String province Province? @relation(fields: [provinceId], references: [id], onDelete: SetNull) provinceId String? district District? @relation(fields: [districtId], references: [id], onDelete: SetNull) districtId String? subDistrict SubDistrict? @relation(fields: [subDistrictId], references: [id], onDelete: SetNull) subDistrictId String? zipCode String email String telephoneNo String latitude String longitude String status Status @default(CREATED) createdBy String? createdAt DateTime @default(now()) updateBy String? updatedAt DateTime @updatedAt employee Employee[] } model Employee { id String @id @default(uuid()) code String nrcNo String firstName String firstNameEN String lastName String lastNameEN String dateOfBirth DateTime gender String nationality String address String addressEN String province Province? @relation(fields: [provinceId], references: [id], onDelete: SetNull) provinceId String? district District? @relation(fields: [districtId], references: [id], onDelete: SetNull) districtId String? subDistrict SubDistrict? @relation(fields: [subDistrictId], references: [id], onDelete: SetNull) subDistrictId String? zipCode String email String telephoneNo String arrivalBarricade String arrivalCardNo String customerBranch CustomerBranch? @relation(fields: [customerBranchId], references: [id], onDelete: SetNull) customerBranchId String? status Status @default(CREATED) createdBy String? createdAt DateTime @default(now()) updateBy String? updatedAt DateTime @updatedAt employeeCheckup EmployeeCheckup[] employeeWork EmployeeWork[] employeeOtherInfo EmployeeOtherInfo[] } model EmployeeCheckup { id String @id @default(uuid()) employee Employee @relation(fields: [employeeId], references: [id], onDelete: Cascade) employeeId String checkupResult String checkupType String province Province? @relation(fields: [provinceId], references: [id], onDelete: SetNull) provinceId String? hospitalName String remark String medicalBenefitScheme String insuranceCompany String coverageStartDate DateTime coverageExpireDate DateTime createdBy String? createdAt DateTime @default(now()) updateBy String? updatedAt DateTime @updatedAt } model EmployeeWork { id String @id @default(uuid()) employee Employee @relation(fields: [employeeId], references: [id], onDelete: Cascade) employeeId String ownerName String positionName String jobType String workplace String workPermitNo String workPermitIssuDate DateTime workPermitExpireDate DateTime workEndDate DateTime createdBy String? createdAt DateTime @default(now()) updateBy String? updatedAt DateTime @updatedAt } model EmployeeOtherInfo { id String @id @default(uuid()) employee Employee @relation(fields: [employeeId], references: [id], onDelete: Cascade) employeeId String citizenId String fatherFullName String motherFullName String birthPlace String createdBy String? createdAt DateTime @default(now()) updateBy String? updatedAt DateTime @updatedAt } model Service { id String @id @default(uuid()) code String name String detail String status Status @default(CREATED) createdBy String? createdAt DateTime @default(now()) updateBy String? updatedAt DateTime @updatedAt work Work[] } model Work { id String @id @default(uuid()) order Int name String service Service @relation(fields: [serviceId], references: [id], onDelete: Cascade) serviceId String status Status @default(CREATED) createdBy String? createdAt DateTime @default(now()) updateBy String? updatedAt DateTime @updatedAt WorkProduct WorkProduct[] } model WorkProduct { id String @id @default(uuid()) work Work @relation(fields: [workId], references: [id], onDelete: Cascade) workId String createdBy String? createdAt DateTime @default(now()) updateBy String? updatedAt DateTime @updatedAt } model ProductGroup { id String @id @default(uuid()) code String name String detail String remark String status Status @default(CREATED) createdBy String? createdAt DateTime @default(now()) updateBy String? updatedAt DateTime @updatedAt Product Product[] } model ProductType { id String @id @default(uuid()) code String name String detail String remark String status Status @default(CREATED) createdBy String? createdAt DateTime @default(now()) updateBy String? updatedAt DateTime @updatedAt product Product[] } model Product { id String @id @default(uuid()) code String name String detail String process String price Int agentPrice Int serviceCharge Int imageUrl String status Status @default(CREATED) productType ProductType? @relation(fields: [productTypeId], references: [id], onDelete: SetNull) productTypeId String? productGroup ProductGroup? @relation(fields: [productGroupId], references: [id], onDelete: SetNull) productGroupId String? createdBy String? createdAt DateTime @default(now()) updateBy String? updatedAt DateTime @updatedAt }