From 9358cac3f892045631747edd00af1357b5225d81 Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Mon, 30 Sep 2024 09:48:35 +0700 Subject: [PATCH] fix: relation --- .../migration.sql | 11 +++++++++++ prisma/schema.prisma | 13 +++++-------- src/controllers/04-product-group-controller.ts | 3 ++- 3 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 prisma/migrations/20240930024850_update_accident_relation/migration.sql diff --git a/prisma/migrations/20240930024850_update_accident_relation/migration.sql b/prisma/migrations/20240930024850_update_accident_relation/migration.sql new file mode 100644 index 0000000..2a3b321 --- /dev/null +++ b/prisma/migrations/20240930024850_update_accident_relation/migration.sql @@ -0,0 +1,11 @@ +/* + Warnings: + + - You are about to drop the column `customerId` on the `Quotation` table. All the data in the column will be lost. + +*/ +-- DropForeignKey +ALTER TABLE "Quotation" DROP CONSTRAINT "Quotation_customerId_fkey"; + +-- AlterTable +ALTER TABLE "Quotation" DROP COLUMN "customerId"; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index fd66618..8be3fdd 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -444,8 +444,7 @@ model Customer { updatedBy User? @relation(name: "CustomerUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull) updatedByUserId String? - branch CustomerBranch[] - quotation Quotation[] + branch CustomerBranch[] } model CustomerBranch { @@ -1056,14 +1055,12 @@ model Quotation { vatExcluded Float finalPrice Float - createdAt DateTime @default(now()) - createdBy User? @relation(name: "QuotationCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull) + createdAt DateTime @default(now()) + createdBy User? @relation(name: "QuotationCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull) createdByUserId String? - updatedAt DateTime @updatedAt - updatedBy User? @relation(name: "QuotationUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull) + updatedAt DateTime @updatedAt + updatedBy User? @relation(name: "QuotationUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull) updatedByUserId String? - Customer Customer? @relation(fields: [customerId], references: [id]) - customerId String? } model QuotationPaySplit { diff --git a/src/controllers/04-product-group-controller.ts b/src/controllers/04-product-group-controller.ts index f1a4fe8..b6bb6f3 100644 --- a/src/controllers/04-product-group-controller.ts +++ b/src/controllers/04-product-group-controller.ts @@ -25,6 +25,7 @@ import { createPermCondition, } from "../services/permission"; import { filterStatus } from "../services/prisma"; +import { notFoundError } from "../utils/error"; type ProductGroupCreate = { name: string; @@ -56,7 +57,7 @@ function globalAllow(user: RequestWithUser["user"]) { return allowList.some((v) => user.roles?.includes(v)); } -const permissionCond = createPermCondition(globalAllow); +const permissionCond = createPermCondition((_) => true); const permissionCheck = createPermCheck(globalAllow); @Route("api/v1/product-group")