jws-backend/prisma/schema.prisma

497 lines
10 KiB
Text
Raw Normal View History

2024-04-01 13:28:43 +07:00
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Province {
2024-04-01 19:47:56 +07:00
id String @id @default(uuid())
name String
2024-04-01 13:28:43 +07:00
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 {
2024-04-01 19:47:56 +07:00
id String @id @default(uuid())
name String
2024-04-01 13:28:43 +07:00
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 {
2024-04-01 19:47:56 +07:00
id String @id @default(uuid())
name String
2024-04-01 13:28:43 +07:00
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[]
}
2024-04-02 10:48:35 +07:00
enum Status {
CREATED
2024-04-05 10:41:03 +07:00
ACTIVE
INACTIVE
2024-04-02 10:48:35 +07:00
}
2024-04-01 13:28:43 +07:00
model Branch {
id String @id @default(uuid())
2024-04-09 13:05:49 +07:00
code String
2024-04-01 13:28:43 +07:00
taxNo String
name String
2024-04-01 13:28:43 +07:00
nameEN String
2024-04-04 15:27:57 +07:00
address String
2024-04-01 13:28:43 +07:00
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?
2024-04-02 10:48:35 +07:00
status Status @default(CREATED)
2024-04-01 13:28:43 +07:00
createdBy String?
createdAt DateTime @default(now())
updateBy String?
updatedAt DateTime @updatedAt
branch Branch[] @relation(name: "HeadOfficeRelation")
contact BranchContact[]
user BranchUser[]
}
model BranchContact {
2024-04-02 10:48:35 +07:00
id String @id @default(uuid())
telephoneNo String
lineId String
2024-04-01 13:28:43 +07:00
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
}
2024-04-09 13:05:49 +07:00
enum UserType {
USER
MESSENGER
DELEGATE
AGENCY
}
2024-04-01 13:28:43 +07:00
model User {
id String @id @default(uuid())
2024-04-02 10:48:35 +07:00
keycloakId String
2024-04-09 13:05:49 +07:00
code String?
firstName String
2024-04-01 19:47:56 +07:00
firstNameEN String
lastName String
2024-04-01 19:47:56 +07:00
lastNameEN String
2024-04-05 16:46:47 +07:00
gender String
2024-04-01 13:28:43 +07:00
2024-04-04 15:27:57 +07:00
address String
2024-04-01 13:28:43 +07:00
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?
2024-04-01 13:28:43 +07:00
startDate DateTime?
retireDate DateTime?
2024-04-01 13:28:43 +07:00
2024-04-09 13:05:49 +07:00
userType UserType
2024-04-01 13:28:43 +07:00
userRole String
discountCondition String?
2024-04-01 13:28:43 +07:00
licenseNo String?
licenseIssueDate DateTime?
licenseExpireDate DateTime?
2024-04-01 13:28:43 +07:00
sourceNationality String?
importNationality String?
2024-04-01 13:28:43 +07:00
trainingPlace String?
2024-04-01 13:28:43 +07:00
2024-04-02 10:48:35 +07:00
status Status @default(CREATED)
2024-04-01 13:28:43 +07:00
createdBy String?
createdAt DateTime @default(now())
updateBy String?
updatedAt DateTime @updatedAt
branch BranchUser[]
}
2024-04-09 13:56:15 +07:00
enum CustomerType {
CORP
PERS
}
2024-04-01 13:28:43 +07:00
model Customer {
2024-04-09 13:56:15 +07:00
id String @id @default(uuid())
2024-04-09 13:05:49 +07:00
code String
2024-04-09 13:56:15 +07:00
customerType CustomerType
2024-04-04 15:27:57 +07:00
customerName String
2024-04-01 13:28:43 +07:00
customerNameEN String
status Status @default(CREATED)
2024-04-01 13:28:43 +07:00
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
2024-04-01 13:28:43 +07:00
nameEN String
customer Customer @relation(fields: [customerId], references: [id], onDelete: Cascade)
customerId String
taxNo String
registerName String
registerDate DateTime
authorizedCapital String
2024-04-04 17:42:52 +07:00
address String
2024-04-01 13:28:43 +07:00
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
2024-04-04 17:42:52 +07:00
status Status @default(CREATED)
2024-04-01 13:28:43 +07:00
createdBy String?
createdAt DateTime @default(now())
updateBy String?
updatedAt DateTime @updatedAt
employee Employee[]
}
model Employee {
id String @id @default(uuid())
code String
2024-04-04 17:42:52 +07:00
nrcNo String
firstName String
firstNameEN String
lastName String
lastNameEN String
2024-04-01 13:28:43 +07:00
dateOfBirth DateTime
gender String
nationality String
2024-04-04 15:27:57 +07:00
address String
2024-04-01 13:28:43 +07:00
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)
2024-04-01 13:28:43 +07:00
createdBy String?
createdAt DateTime @default(now())
updateBy String?
updatedAt DateTime @updatedAt
employeeCheckup EmployeeCheckup[]
employeeWork EmployeeWork[]
2024-04-04 17:42:52 +07:00
employeeOtherInfo EmployeeOtherInfo[]
2024-04-01 13:28:43 +07:00
}
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)
2024-04-01 13:28:43 +07:00
createdBy String?
createdAt DateTime @default(now())
updateBy String?
updatedAt DateTime @updatedAt
work Work[]
}
model Work {
id String @id @default(uuid())
order Int
2024-04-01 13:28:43 +07:00
name String
service Service @relation(fields: [serviceId], references: [id], onDelete: Cascade)
serviceId String
status Status @default(CREATED)
2024-04-01 13:28:43 +07:00
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)
2024-04-01 13:28:43 +07:00
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)
2024-04-01 13:28:43 +07:00
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)
2024-04-01 13:28:43 +07:00
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
}