feat: add original service reference

This commit is contained in:
Methapon2001 2024-07-23 15:43:06 +07:00
parent bada98d12d
commit fbf7f6c968
3 changed files with 18 additions and 1 deletions

View file

@ -0,0 +1,11 @@
/*
Warnings:
- Added the required column `refServiceId` to the `QuotationService` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "QuotationService" ADD COLUMN "refServiceId" TEXT NOT NULL;
-- AddForeignKey
ALTER TABLE "QuotationService" ADD CONSTRAINT "QuotationService_refServiceId_fkey" FOREIGN KEY ("refServiceId") REFERENCES "Service"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View file

@ -718,7 +718,8 @@ model Service {
status Status @default(CREATED) status Status @default(CREATED)
statusOrder Int @default(0) statusOrder Int @default(0)
work Work[] work Work[]
quotationService QuotationService[]
productType ProductType? @relation(fields: [productTypeId], references: [id], onDelete: SetNull) productType ProductType? @relation(fields: [productTypeId], references: [id], onDelete: SetNull)
productTypeId String? productTypeId String?
@ -854,8 +855,12 @@ model QuotationService {
work QuotationServiceWork[] work QuotationServiceWork[]
refServiceId String
refService Service @relation(fields: [refServiceId], references: [id])
quotation Quotation @relation(fields: [quotationId], references: [id]) quotation Quotation @relation(fields: [quotationId], references: [id])
quotationId String quotationId String
serviceId String
} }
model QuotationServiceWork { model QuotationServiceWork {

View file

@ -420,6 +420,7 @@ export class QuotationController extends Controller {
detail: a.detail, detail: a.detail,
attributes: a.attributes, attributes: a.attributes,
quotationId: quotation.id, quotationId: quotation.id,
refServiceId: a.id,
}, },
}); });