refactor: user relation
This commit is contained in:
parent
a74d8b63b1
commit
2bd30b735d
21 changed files with 607 additions and 185 deletions
238
prisma/migrations/20240701062318_user_relation/migration.sql
Normal file
238
prisma/migrations/20240701062318_user_relation/migration.sql
Normal file
|
|
@ -0,0 +1,238 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `createdBy` on the `Branch` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `Branch` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `BranchContact` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `BranchContact` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `BranchUser` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `BranchUser` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `Customer` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `Customer` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `CustomerBranch` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `CustomerBranch` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `Employee` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `Employee` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `EmployeeCheckup` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `EmployeeCheckup` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `EmployeeHistory` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `EmployeeOtherInfo` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `EmployeeOtherInfo` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `EmployeeWork` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `EmployeeWork` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `Product` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `Product` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `ProductGroup` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `ProductGroup` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `ProductType` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `ProductType` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `Service` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `Service` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `User` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `User` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `Work` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `Work` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `createdBy` on the `WorkProduct` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedBy` on the `WorkProduct` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "Branch" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "BranchContact" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "BranchUser" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Customer" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "CustomerBranch" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Employee" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "EmployeeCheckup" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "EmployeeHistory" DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ALTER COLUMN "updatedAt" DROP DEFAULT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "EmployeeOtherInfo" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "EmployeeWork" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Product" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "ProductGroup" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "ProductType" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Service" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "User" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Work" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "WorkProduct" DROP COLUMN "createdBy",
|
||||
DROP COLUMN "updatedBy",
|
||||
ADD COLUMN "createdByUserId" TEXT,
|
||||
ADD COLUMN "updatedByUserId" TEXT;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Branch" ADD CONSTRAINT "Branch_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Branch" ADD CONSTRAINT "Branch_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "BranchContact" ADD CONSTRAINT "BranchContact_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "BranchContact" ADD CONSTRAINT "BranchContact_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "BranchUser" ADD CONSTRAINT "BranchUser_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "BranchUser" ADD CONSTRAINT "BranchUser_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "User" ADD CONSTRAINT "User_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "User" ADD CONSTRAINT "User_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Customer" ADD CONSTRAINT "Customer_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Customer" ADD CONSTRAINT "Customer_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "CustomerBranch" ADD CONSTRAINT "CustomerBranch_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "CustomerBranch" ADD CONSTRAINT "CustomerBranch_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Employee" ADD CONSTRAINT "Employee_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Employee" ADD CONSTRAINT "Employee_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EmployeeHistory" ADD CONSTRAINT "EmployeeHistory_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EmployeeCheckup" ADD CONSTRAINT "EmployeeCheckup_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EmployeeCheckup" ADD CONSTRAINT "EmployeeCheckup_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EmployeeWork" ADD CONSTRAINT "EmployeeWork_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EmployeeWork" ADD CONSTRAINT "EmployeeWork_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EmployeeOtherInfo" ADD CONSTRAINT "EmployeeOtherInfo_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EmployeeOtherInfo" ADD CONSTRAINT "EmployeeOtherInfo_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Service" ADD CONSTRAINT "Service_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Service" ADD CONSTRAINT "Service_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Work" ADD CONSTRAINT "Work_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Work" ADD CONSTRAINT "Work_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "WorkProduct" ADD CONSTRAINT "WorkProduct_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "WorkProduct" ADD CONSTRAINT "WorkProduct_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ProductGroup" ADD CONSTRAINT "ProductGroup_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ProductGroup" ADD CONSTRAINT "ProductGroup_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ProductType" ADD CONSTRAINT "ProductType_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ProductType" ADD CONSTRAINT "ProductType_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Product" ADD CONSTRAINT "Product_createdByUserId_fkey" FOREIGN KEY ("createdByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Product" ADD CONSTRAINT "Product_updatedByUserId_fkey" FOREIGN KEY ("updatedByUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
|
@ -22,7 +22,7 @@ model Menu {
|
|||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
parent Menu? @relation(name: "MenuRelation", fields: [parentId], references: [id])
|
||||
|
|
@ -45,7 +45,7 @@ model RoleMenuPermission {
|
|||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ model UserMenuPermission {
|
|||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ model MenuComponent {
|
|||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
roleMenuComponentPermission RoleMenuComponentPermission[]
|
||||
userMennuComponentPermission UserMenuComponentPermission[]
|
||||
|
|
@ -94,7 +94,7 @@ model RoleMenuComponentPermission {
|
|||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ model UserMenuComponentPermission {
|
|||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
|
|
@ -127,7 +127,7 @@ model Province {
|
|||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
district District[]
|
||||
|
|
@ -148,7 +148,7 @@ model District {
|
|||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
subDistrict SubDistrict[]
|
||||
|
|
@ -169,7 +169,7 @@ model SubDistrict {
|
|||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
branch Branch[]
|
||||
|
|
@ -220,10 +220,12 @@ model Branch {
|
|||
status Status @default(CREATED)
|
||||
statusOrder Int @default(0)
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
createdBy User? @relation(name: "BranchCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||
createdByUserId String?
|
||||
updatedAt DateTime @updatedAt
|
||||
updatedBy User? @relation(name: "BranchUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
||||
updatedByUserId String?
|
||||
|
||||
branch Branch[] @relation(name: "HeadOfficeRelation")
|
||||
contact BranchContact[]
|
||||
|
|
@ -237,10 +239,12 @@ model BranchContact {
|
|||
branch Branch @relation(fields: [branchId], references: [id], onDelete: Cascade)
|
||||
branchId String
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
createdBy User? @relation(name: "BranchContactCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||
createdByUserId String?
|
||||
updatedAt DateTime @updatedAt
|
||||
updatedBy User? @relation(name: "BranchContactUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
||||
updatedByUserId String?
|
||||
}
|
||||
|
||||
model BranchUser {
|
||||
|
|
@ -252,10 +256,12 @@ model BranchUser {
|
|||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
userId String
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
createdBy User? @relation(name: "BranchUserCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||
createdByUserId String?
|
||||
updatedAt DateTime @updatedAt
|
||||
updatedBy User? @relation(name: "BranchUserUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
||||
updatedByUserId String?
|
||||
}
|
||||
|
||||
enum UserType {
|
||||
|
|
@ -321,15 +327,51 @@ model User {
|
|||
status Status @default(CREATED)
|
||||
statusOrder Int @default(0)
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
createdBy User? @relation(name: "UserCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||
createdByUserId String?
|
||||
updatedAt DateTime @updatedAt
|
||||
updatedBy User? @relation(name: "UserUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
||||
updatedByUserId String?
|
||||
|
||||
branch BranchUser[]
|
||||
userMenuPermission UserMenuPermission[]
|
||||
userMenuComponentPermission UserMenuComponentPermission[]
|
||||
employeeHistory EmployeeHistory[]
|
||||
|
||||
userCreated User[] @relation("UserCreatedByUser")
|
||||
userUpdated User[] @relation("UserUpdatedByUser")
|
||||
branchCreated Branch[] @relation("BranchCreatedByUser")
|
||||
branchUpdated Branch[] @relation("BranchUpdatedByUser")
|
||||
branchContactCreated BranchContact[] @relation("BranchContactCreatedByUser")
|
||||
branchContactUpdated BranchContact[] @relation("BranchContactUpdatedByUser")
|
||||
branchUserCreated BranchUser[] @relation("BranchUserCreatedByUser")
|
||||
branchUserUpdated BranchUser[] @relation("BranchUserUpdatedByUser")
|
||||
customerCreated Customer[] @relation("CustomerCreatedByUser")
|
||||
customerUpdated Customer[] @relation("CustomerUpdatedByUser")
|
||||
customerBranchCreated CustomerBranch[] @relation("CustomerBranchCreatedByUser")
|
||||
customerBranchUpdated CustomerBranch[] @relation("CustomerBranchUpdatedByUser")
|
||||
emplyeeCreated Employee[] @relation("EmployeeCreatedByUser")
|
||||
employeUpdated Employee[] @relation("EmployeeUpdatedByUser")
|
||||
employeeHistoryCreated EmployeeHistory[] @relation("EmployeeHistoryCreatedByUser")
|
||||
employeeHistoryUpdated EmployeeHistory[] @relation("EmployeeHistoryUpdatedByUser")
|
||||
employeeCheckupCreated EmployeeCheckup[] @relation("EmployeeCheckupCreatedByUser")
|
||||
employeeCheckupUpdated EmployeeCheckup[] @relation("EmployeeCheckupUpdatedByUser")
|
||||
employeeWorkCreated EmployeeWork[] @relation("EmployeeWorkCreatedByUser")
|
||||
employeeWorkUpdated EmployeeWork[] @relation("EmployeeWorkUpdatedByUser")
|
||||
employeeOtherInfoCreated EmployeeOtherInfo[] @relation("EmployeeOtherInfoCreatedByUser")
|
||||
employeeOtherInfoUpdated EmployeeOtherInfo[] @relation("EmployeeOtherInfoUpdatedByUser")
|
||||
serviceCreated Service[] @relation("ServiceCreatedByUser")
|
||||
serviceUpdated Service[] @relation("ServiceUpdatedByUser")
|
||||
workCreated Work[] @relation("WorkCreatedByUser")
|
||||
workUpdated Work[] @relation("WorkUpdatedByUser")
|
||||
workProductCreated WorkProduct[] @relation("WorkProductCreatedByUser")
|
||||
workProductUpdated WorkProduct[] @relation("WorkProductUpdatedByUser")
|
||||
productGroupCreated ProductGroup[] @relation("ProductGroupCreatedByUser")
|
||||
productGroupUpdated ProductGroup[] @relation("ProductGroupUpdatedByUser")
|
||||
productTypeCreated ProductType[] @relation("ProductTypeCreatedByUser")
|
||||
productTypeUpdated ProductType[] @relation("ProductTypeUpdatedByUser")
|
||||
productCreated Product[] @relation("ProductCreatedByUser")
|
||||
productUpdated Product[] @relation("ProductUpdatedByUser")
|
||||
}
|
||||
|
||||
enum CustomerType {
|
||||
|
|
@ -350,10 +392,12 @@ model Customer {
|
|||
status Status @default(CREATED)
|
||||
statusOrder Int @default(0)
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
createdBy User? @relation(name: "CustomerCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||
createdByUserId String?
|
||||
updatedAt DateTime @updatedAt
|
||||
updatedBy User? @relation(name: "CustomerUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
||||
updatedByUserId String?
|
||||
|
||||
branch CustomerBranch[]
|
||||
}
|
||||
|
|
@ -405,10 +449,12 @@ model CustomerBranch {
|
|||
status Status @default(CREATED)
|
||||
statusOrder Int @default(0)
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
createdBy User? @relation(name: "CustomerBranchCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||
createdByUserId String?
|
||||
updatedAt DateTime @updatedAt
|
||||
updatedBy User? @relation(name: "CustomerBranchUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
||||
updatedByUserId String?
|
||||
|
||||
employee Employee[]
|
||||
}
|
||||
|
|
@ -465,10 +511,12 @@ model Employee {
|
|||
status Status @default(CREATED)
|
||||
statusOrder Int @default(0)
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
createdBy User? @relation(name: "EmployeeCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||
createdByUserId String?
|
||||
updatedAt DateTime @updatedAt
|
||||
updatedBy User? @relation(name: "EmployeeUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
||||
updatedByUserId String?
|
||||
|
||||
employeeCheckup EmployeeCheckup[]
|
||||
employeeWork EmployeeWork[]
|
||||
|
|
@ -485,10 +533,12 @@ model EmployeeHistory {
|
|||
|
||||
timestamp DateTime @default(now())
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
createdBy User? @relation(name: "EmployeeHistoryCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||
createdByUserId String?
|
||||
updatedAt DateTime @updatedAt
|
||||
updatedBy User? @relation(name: "EmployeeHistoryUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
||||
updatedByUserId String?
|
||||
updatedByUser User? @relation(fields: [updatedByUserId], references: [id])
|
||||
updatedBy String?
|
||||
updatedAt DateTime @default(now())
|
||||
|
||||
masterId String
|
||||
master Employee @relation(fields: [masterId], references: [id], onDelete: Cascade)
|
||||
|
|
@ -513,10 +563,12 @@ model EmployeeCheckup {
|
|||
coverageStartDate DateTime?
|
||||
coverageExpireDate DateTime?
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
createdBy User? @relation(name: "EmployeeCheckupCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||
createdByUserId String?
|
||||
updatedAt DateTime @updatedAt
|
||||
updatedBy User? @relation(name: "EmployeeCheckupUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
||||
updatedByUserId String?
|
||||
}
|
||||
|
||||
model EmployeeWork {
|
||||
|
|
@ -535,10 +587,12 @@ model EmployeeWork {
|
|||
workEndDate DateTime?
|
||||
remark String?
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
createdBy User? @relation(name: "EmployeeWorkCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||
createdByUserId String?
|
||||
updatedAt DateTime @updatedAt
|
||||
updatedBy User? @relation(name: "EmployeeWorkUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
||||
updatedByUserId String?
|
||||
}
|
||||
|
||||
model EmployeeOtherInfo {
|
||||
|
|
@ -560,10 +614,12 @@ model EmployeeOtherInfo {
|
|||
motherFirstNameEN String?
|
||||
motherLastNameEN String?
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
createdBy User? @relation(name: "EmployeeOtherInfoCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||
createdByUserId String?
|
||||
updatedAt DateTime @updatedAt
|
||||
updatedBy User? @relation(name: "EmployeeOtherInfoUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
||||
updatedByUserId String?
|
||||
}
|
||||
|
||||
model Service {
|
||||
|
|
@ -579,10 +635,12 @@ model Service {
|
|||
|
||||
work Work[]
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
createdBy User? @relation(name: "ServiceCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||
createdByUserId String?
|
||||
updatedAt DateTime @updatedAt
|
||||
updatedBy User? @relation(name: "ServiceUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
||||
updatedByUserId String?
|
||||
}
|
||||
|
||||
model Work {
|
||||
|
|
@ -598,10 +656,12 @@ model Work {
|
|||
service Service? @relation(fields: [serviceId], references: [id], onDelete: Cascade)
|
||||
serviceId String?
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
createdBy User? @relation(name: "WorkCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||
createdByUserId String?
|
||||
updatedAt DateTime @updatedAt
|
||||
updatedBy User? @relation(name: "WorkUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
||||
updatedByUserId String?
|
||||
|
||||
productOnWork WorkProduct[]
|
||||
}
|
||||
|
|
@ -613,10 +673,12 @@ model WorkProduct {
|
|||
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
|
||||
productId String
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
createdBy User? @relation(name: "WorkProductCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||
createdByUserId String?
|
||||
updatedAt DateTime @updatedAt
|
||||
updatedBy User? @relation(name: "WorkProductUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
||||
updatedByUserId String?
|
||||
|
||||
@@id([workId, productId])
|
||||
}
|
||||
|
|
@ -632,10 +694,12 @@ model ProductGroup {
|
|||
status Status @default(CREATED)
|
||||
statusOrder Int @default(0)
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
createdBy User? @relation(name: "ProductGroupCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||
createdByUserId String?
|
||||
updatedAt DateTime @updatedAt
|
||||
updatedBy User? @relation(name: "ProductGroupUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
||||
updatedByUserId String?
|
||||
|
||||
type ProductType[]
|
||||
}
|
||||
|
|
@ -651,10 +715,12 @@ model ProductType {
|
|||
status Status @default(CREATED)
|
||||
statusOrder Int @default(0)
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
createdBy User? @relation(name: "ProductTypeCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||
createdByUserId String?
|
||||
updatedAt DateTime @updatedAt
|
||||
updatedBy User? @relation(name: "ProductTypeUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
||||
updatedByUserId String?
|
||||
|
||||
productGroup ProductGroup @relation(fields: [productGroupId], references: [id], onDelete: Cascade)
|
||||
productGroupId String
|
||||
|
|
@ -683,8 +749,10 @@ model Product {
|
|||
|
||||
workProduct WorkProduct[]
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
createdBy User? @relation(name: "ProductCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||
createdByUserId String?
|
||||
updatedAt DateTime @updatedAt
|
||||
updatedBy User? @relation(name: "ProductUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
||||
updatedByUserId String?
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue