diff --git a/prisma/migrations/20241004093717_update_quotation_structure/migration.sql b/prisma/migrations/20241004093717_update_quotation_structure/migration.sql new file mode 100644 index 0000000..6b4adc6 --- /dev/null +++ b/prisma/migrations/20241004093717_update_quotation_structure/migration.sql @@ -0,0 +1,16 @@ +-- AlterTable +ALTER TABLE "Quotation" ALTER COLUMN "quotationStatus" SET DEFAULT 'PaymentWait'; + +-- CreateTable +CREATE TABLE "QuotationProductServiceWorker" ( + "productServiceId" TEXT NOT NULL, + "employeeId" TEXT NOT NULL, + + CONSTRAINT "QuotationProductServiceWorker_pkey" PRIMARY KEY ("productServiceId","employeeId") +); + +-- AddForeignKey +ALTER TABLE "QuotationProductServiceWorker" ADD CONSTRAINT "QuotationProductServiceWorker_productServiceId_fkey" FOREIGN KEY ("productServiceId") REFERENCES "QuotationProductServiceList"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "QuotationProductServiceWorker" ADD CONSTRAINT "QuotationProductServiceWorker_employeeId_fkey" FOREIGN KEY ("employeeId") REFERENCES "Employee"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/20241004093913_update_constraints/migration.sql b/prisma/migrations/20241004093913_update_constraints/migration.sql new file mode 100644 index 0000000..4b7cf6b --- /dev/null +++ b/prisma/migrations/20241004093913_update_constraints/migration.sql @@ -0,0 +1,11 @@ +-- DropForeignKey +ALTER TABLE "QuotationProductServiceWorker" DROP CONSTRAINT "QuotationProductServiceWorker_employeeId_fkey"; + +-- DropForeignKey +ALTER TABLE "QuotationProductServiceWorker" DROP CONSTRAINT "QuotationProductServiceWorker_productServiceId_fkey"; + +-- AddForeignKey +ALTER TABLE "QuotationProductServiceWorker" ADD CONSTRAINT "QuotationProductServiceWorker_productServiceId_fkey" FOREIGN KEY ("productServiceId") REFERENCES "QuotationProductServiceList"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "QuotationProductServiceWorker" ADD CONSTRAINT "QuotationProductServiceWorker_employeeId_fkey" FOREIGN KEY ("employeeId") REFERENCES "Employee"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index a2148a8..35d3b04 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -728,8 +728,9 @@ model Employee { employeeWork EmployeeWork[] employeeOtherInfo EmployeeOtherInfo? - editHistory EmployeeHistory[] - quotationWorker QuotationWorker[] + editHistory EmployeeHistory[] + quotationWorker QuotationWorker[] + quotationProductServiceWorker QuotationProductServiceWorker[] } model EmployeeHistory { @@ -1033,7 +1034,7 @@ model Quotation { status Status @default(CREATED) statusOrder Int @default(0) - quotationStatus QuotationStatus @default(PaymentPending) + quotationStatus QuotationStatus @default(PaymentWait) code String @@ -1116,4 +1117,16 @@ model QuotationProductServiceList { serviceId String? service Service? @relation(fields: [serviceId], references: [id]) + + worker QuotationProductServiceWorker[] +} + +model QuotationProductServiceWorker { + productService QuotationProductServiceList @relation(fields: [productServiceId], references: [id], onDelete: Cascade) + productServiceId String + + employee Employee @relation(fields: [employeeId], references: [id], onDelete: Cascade) + employeeId String + + @@id([productServiceId, employeeId]) }