feat: refactor permission product service
This commit is contained in:
parent
f9cc39522c
commit
8c0932f6d8
4 changed files with 189 additions and 292 deletions
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `registeredBranchId` on the `Product` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `registeredBranchId` on the `Service` table. All the data in the column will be lost.
|
||||
- Made the column `productGroupId` on table `Product` required. This step will fail if there are existing NULL values in that column.
|
||||
- Made the column `registeredBranchId` on table `ProductGroup` required. This step will fail if there are existing NULL values in that column.
|
||||
- Made the column `productGroupId` on table `Service` required. This step will fail if there are existing NULL values in that column.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Product" DROP CONSTRAINT "Product_productGroupId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Product" DROP CONSTRAINT "Product_registeredBranchId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "ProductGroup" DROP CONSTRAINT "ProductGroup_registeredBranchId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Service" DROP CONSTRAINT "Service_productGroupId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Service" DROP CONSTRAINT "Service_registeredBranchId_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Product" DROP COLUMN "registeredBranchId",
|
||||
ADD COLUMN "shared" BOOLEAN NOT NULL DEFAULT false,
|
||||
ALTER COLUMN "productGroupId" SET NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "ProductGroup" ALTER COLUMN "registeredBranchId" SET NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Service" DROP COLUMN "registeredBranchId",
|
||||
ADD COLUMN "shared" BOOLEAN NOT NULL DEFAULT false,
|
||||
ALTER COLUMN "productGroupId" SET NOT NULL;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ProductGroup" ADD CONSTRAINT "ProductGroup_registeredBranchId_fkey" FOREIGN KEY ("registeredBranchId") REFERENCES "Branch"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Product" ADD CONSTRAINT "Product_productGroupId_fkey" FOREIGN KEY ("productGroupId") REFERENCES "ProductGroup"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Service" ADD CONSTRAINT "Service_productGroupId_fkey" FOREIGN KEY ("productGroupId") REFERENCES "ProductGroup"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
|
@ -238,8 +238,6 @@ model Branch {
|
|||
contact BranchContact[]
|
||||
user BranchUser[]
|
||||
|
||||
productRegistration Product[]
|
||||
serviceRegistration Service[]
|
||||
customerRegistration Customer[]
|
||||
productGroup ProductGroup[]
|
||||
}
|
||||
|
|
@ -662,8 +660,8 @@ model ProductGroup {
|
|||
status Status @default(CREATED)
|
||||
statusOrder Int @default(0)
|
||||
|
||||
registeredBranchId String?
|
||||
registeredBranch Branch? @relation(fields: [registeredBranchId], references: [id])
|
||||
registeredBranchId String
|
||||
registeredBranch Branch @relation(fields: [registeredBranchId], references: [id])
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
createdBy User? @relation(name: "ProductGroupCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||
|
|
@ -696,11 +694,8 @@ model Product {
|
|||
|
||||
remark String?
|
||||
|
||||
productGroup ProductGroup? @relation(fields: [productGroupId], references: [id], onDelete: SetNull)
|
||||
productGroupId String?
|
||||
|
||||
registeredBranchId String?
|
||||
registeredBranch Branch? @relation(fields: [registeredBranchId], references: [id])
|
||||
productGroup ProductGroup @relation(fields: [productGroupId], references: [id], onDelete: Cascade)
|
||||
productGroupId String
|
||||
|
||||
workProduct WorkProduct[]
|
||||
quotationServiceWorkProduct QuotationServiceWorkProduct[]
|
||||
|
|
@ -729,11 +724,8 @@ model Service {
|
|||
work Work[]
|
||||
quotationService QuotationService[]
|
||||
|
||||
productGroup ProductGroup? @relation(fields: [productGroupId], references: [id], onDelete: SetNull)
|
||||
productGroupId String?
|
||||
|
||||
registeredBranchId String?
|
||||
registeredBranch Branch? @relation(fields: [registeredBranchId], references: [id])
|
||||
productGroup ProductGroup @relation(fields: [productGroupId], references: [id], onDelete: Cascade)
|
||||
productGroupId String
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
createdBy User? @relation(name: "ServiceCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue