chore: migration
This commit is contained in:
parent
46a16cf697
commit
f3f27e8f87
1 changed files with 51 additions and 0 deletions
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- The values [Redo] on the enum `RequestWorkStatus` will be removed. If these variants are still used in the database, this will fail.
|
||||
- You are about to drop the column `taskOrderId` on the `RequestWorkStepStatus` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `taskStatus` on the `TaskOrder` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- CreateEnum
|
||||
CREATE TYPE "TaskOrderStatus" AS ENUM ('Pending', 'InProgress', 'Validate', 'Complete', 'Canceled');
|
||||
|
||||
-- AlterEnum
|
||||
BEGIN;
|
||||
CREATE TYPE "RequestWorkStatus_new" AS ENUM ('Pending', 'Ready', 'Waiting', 'InProgress', 'Validate', 'Ended', 'Completed', 'Canceled');
|
||||
ALTER TABLE "RequestWorkStepStatus" ALTER COLUMN "workStatus" DROP DEFAULT;
|
||||
ALTER TABLE "RequestWorkStepStatus" ALTER COLUMN "workStatus" TYPE "RequestWorkStatus_new" USING ("workStatus"::text::"RequestWorkStatus_new");
|
||||
ALTER TYPE "RequestWorkStatus" RENAME TO "RequestWorkStatus_old";
|
||||
ALTER TYPE "RequestWorkStatus_new" RENAME TO "RequestWorkStatus";
|
||||
DROP TYPE "RequestWorkStatus_old";
|
||||
ALTER TABLE "RequestWorkStepStatus" ALTER COLUMN "workStatus" SET DEFAULT 'Pending';
|
||||
COMMIT;
|
||||
|
||||
-- AlterEnum
|
||||
ALTER TYPE "TaskStatus" ADD VALUE 'Redo';
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "RequestWorkStepStatus" DROP CONSTRAINT "RequestWorkStepStatus_taskOrderId_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "RequestWorkStepStatus" DROP COLUMN "taskOrderId";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "TaskOrder" DROP COLUMN "taskStatus",
|
||||
ADD COLUMN "taskOrderStatus" "TaskOrderStatus" NOT NULL DEFAULT 'Pending';
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Task" (
|
||||
"id" TEXT NOT NULL,
|
||||
"taskStatus" "TaskStatus" NOT NULL DEFAULT 'Pending',
|
||||
"step" INTEGER NOT NULL,
|
||||
"requestWorkId" TEXT NOT NULL,
|
||||
"taskOrderId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "Task_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Task" ADD CONSTRAINT "Task_step_requestWorkId_fkey" FOREIGN KEY ("step", "requestWorkId") REFERENCES "RequestWorkStepStatus"("step", "requestWorkId") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Task" ADD CONSTRAINT "Task_taskOrderId_fkey" FOREIGN KEY ("taskOrderId") REFERENCES "TaskOrder"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
Loading…
Add table
Add a link
Reference in a new issue