jws-backend/prisma/migrations/20241001080358_update_quotation_structure/migration.sql

60 lines
2.3 KiB
MySQL
Raw Permalink Normal View History

/*
Warnings:
- You are about to drop the `QuotationService` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `QuotationServiceWork` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `QuotationServiceWorkProduct` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "QuotationService" DROP CONSTRAINT "QuotationService_quotationId_fkey";
-- DropForeignKey
ALTER TABLE "QuotationService" DROP CONSTRAINT "QuotationService_refServiceId_fkey";
-- DropForeignKey
ALTER TABLE "QuotationServiceWork" DROP CONSTRAINT "QuotationServiceWork_serviceId_fkey";
-- DropForeignKey
ALTER TABLE "QuotationServiceWorkProduct" DROP CONSTRAINT "QuotationServiceWorkProduct_productId_fkey";
-- DropForeignKey
ALTER TABLE "QuotationServiceWorkProduct" DROP CONSTRAINT "QuotationServiceWorkProduct_workId_fkey";
-- DropTable
DROP TABLE "QuotationService";
-- DropTable
DROP TABLE "QuotationServiceWork";
-- DropTable
DROP TABLE "QuotationServiceWorkProduct";
-- CreateTable
CREATE TABLE "QuotationProductServiceList" (
"id" TEXT NOT NULL,
"quotationId" TEXT NOT NULL,
"order" INTEGER NOT NULL,
"vat" DOUBLE PRECISION NOT NULL,
"amount" INTEGER NOT NULL,
"discount" DOUBLE PRECISION NOT NULL,
"pricePerUnit" DOUBLE PRECISION NOT NULL,
"productId" TEXT NOT NULL,
"workId" TEXT,
"serviceId" TEXT,
CONSTRAINT "QuotationProductServiceList_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "QuotationProductServiceList" ADD CONSTRAINT "QuotationProductServiceList_quotationId_fkey" FOREIGN KEY ("quotationId") REFERENCES "Quotation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "QuotationProductServiceList" ADD CONSTRAINT "QuotationProductServiceList_productId_fkey" FOREIGN KEY ("productId") REFERENCES "Product"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "QuotationProductServiceList" ADD CONSTRAINT "QuotationProductServiceList_workId_fkey" FOREIGN KEY ("workId") REFERENCES "Work"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "QuotationProductServiceList" ADD CONSTRAINT "QuotationProductServiceList_serviceId_fkey" FOREIGN KEY ("serviceId") REFERENCES "Service"("id") ON DELETE SET NULL ON UPDATE CASCADE;