/*
  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;
