chore: update migration

This commit is contained in:
Methapon Metanipat 2024-09-06 11:56:37 +07:00
parent e63510850b
commit b5d59ff276
2 changed files with 26 additions and 2 deletions

View file

@ -0,0 +1,20 @@
/*
Warnings:
- Made the column `customerBranchId` on table `Employee` required. This step will fail if there are existing NULL values in that column.
*/
-- DropForeignKey
ALTER TABLE "Employee" DROP CONSTRAINT "Employee_customerBranchId_fkey";
-- AlterTable
ALTER TABLE "Employee" ALTER COLUMN "customerBranchId" SET NOT NULL;
-- AlterTable
ALTER TABLE "ProductGroup" ADD COLUMN "registeredBranchId" TEXT;
-- AddForeignKey
ALTER TABLE "Employee" ADD CONSTRAINT "Employee_customerBranchId_fkey" FOREIGN KEY ("customerBranchId") REFERENCES "CustomerBranch"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "ProductGroup" ADD CONSTRAINT "ProductGroup_registeredBranchId_fkey" FOREIGN KEY ("registeredBranchId") REFERENCES "Branch"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View file

@ -239,6 +239,7 @@ model Branch {
productRegistration Product[]
serviceRegistration Service[]
customerRegistration Customer[]
ProductGroup ProductGroup[]
}
model BranchBank {
@ -533,8 +534,8 @@ model Employee {
entryDate DateTime? @db.Date
workerStatus String?
customerBranch CustomerBranch? @relation(fields: [customerBranchId], references: [id], onDelete: SetNull)
customerBranchId String?
customerBranch CustomerBranch @relation(fields: [customerBranchId], references: [id], onDelete: Cascade)
customerBranchId String
status Status @default(CREATED)
statusOrder Int @default(0)
@ -657,6 +658,9 @@ model ProductGroup {
status Status @default(CREATED)
statusOrder Int @default(0)
registeredBranchId String?
registeredBranch Branch? @relation(fields: [registeredBranchId], references: [id])
createdAt DateTime @default(now())
createdBy User? @relation(name: "ProductGroupCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
createdByUserId String?