chore: update migration
This commit is contained in:
parent
28d002ad65
commit
31ed48d190
4 changed files with 91 additions and 13 deletions
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `serviceId` on the `Work` table. All the data in the column will be lost.
|
||||
- Added the required column `order` to the `WorkProduct` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Work" DROP CONSTRAINT "Work_serviceId_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Work" DROP COLUMN "serviceId";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "WorkProduct" ADD COLUMN "order" INTEGER NOT NULL;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "WorkService" (
|
||||
"id" TEXT NOT NULL,
|
||||
"order" INTEGER NOT NULL,
|
||||
"workId" TEXT NOT NULL,
|
||||
"serviceId" TEXT NOT NULL,
|
||||
"createdBy" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updateBy" TEXT,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"productId" TEXT,
|
||||
|
||||
CONSTRAINT "WorkService_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "WorkService" ADD CONSTRAINT "WorkService_workId_fkey" FOREIGN KEY ("workId") REFERENCES "Work"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "WorkService" ADD CONSTRAINT "WorkService_serviceId_fkey" FOREIGN KEY ("serviceId") REFERENCES "Service"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `order` on the `Work` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "Work" DROP COLUMN "order";
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- The primary key for the `WorkProduct` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- You are about to drop the column `id` on the `WorkProduct` table. All the data in the column will be lost.
|
||||
- The primary key for the `WorkService` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- You are about to drop the column `id` on the `WorkService` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "WorkProduct" DROP CONSTRAINT "WorkProduct_pkey",
|
||||
DROP COLUMN "id",
|
||||
ADD CONSTRAINT "WorkProduct_pkey" PRIMARY KEY ("workId", "productId");
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "WorkService" DROP CONSTRAINT "WorkService_pkey",
|
||||
DROP COLUMN "id",
|
||||
ADD CONSTRAINT "WorkService_pkey" PRIMARY KEY ("workId", "serviceId");
|
||||
|
|
@ -547,30 +547,44 @@ model Service {
|
|||
createdAt DateTime @default(now())
|
||||
updateBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
work Work[]
|
||||
|
||||
workOnService WorkService[]
|
||||
}
|
||||
|
||||
model Work {
|
||||
id String @id @default(uuid())
|
||||
|
||||
order Int
|
||||
name String
|
||||
|
||||
service Service @relation(fields: [serviceId], references: [id], onDelete: Cascade)
|
||||
serviceId String
|
||||
name String
|
||||
|
||||
status Status @default(CREATED)
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updateBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
WorkProduct WorkProduct[]
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updateBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
productOnWork WorkProduct[]
|
||||
serviceOnWork WorkService[]
|
||||
}
|
||||
|
||||
model WorkService {
|
||||
order Int
|
||||
work Work @relation(fields: [workId], references: [id], onDelete: Cascade)
|
||||
workId String
|
||||
service Service @relation(fields: [serviceId], references: [id], onDelete: Cascade)
|
||||
serviceId String
|
||||
|
||||
createdBy String?
|
||||
createdAt DateTime @default(now())
|
||||
updateBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
productId String?
|
||||
|
||||
@@id([workId, serviceId])
|
||||
}
|
||||
|
||||
model WorkProduct {
|
||||
id String @id @default(uuid())
|
||||
|
||||
order Int
|
||||
work Work @relation(fields: [workId], references: [id], onDelete: Cascade)
|
||||
workId String
|
||||
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
|
||||
|
|
@ -580,6 +594,8 @@ model WorkProduct {
|
|||
createdAt DateTime @default(now())
|
||||
updateBy String?
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@id([workId, productId])
|
||||
}
|
||||
|
||||
model ProductGroup {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue