jws-backend/prisma/migrations/20240903070519_drop_relation/migration.sql
2024-09-03 14:06:02 +07:00

41 lines
1.5 KiB
SQL

/*
Warnings:
- You are about to drop the column `productTypeId` on the `Product` table. All the data in the column will be lost.
- You are about to drop the column `productTypeId` on the `Service` table. All the data in the column will be lost.
- You are about to drop the `ProductType` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "Product" DROP CONSTRAINT "Product_productTypeId_fkey";
-- DropForeignKey
ALTER TABLE "ProductType" DROP CONSTRAINT "ProductType_createdByUserId_fkey";
-- DropForeignKey
ALTER TABLE "ProductType" DROP CONSTRAINT "ProductType_productGroupId_fkey";
-- DropForeignKey
ALTER TABLE "ProductType" DROP CONSTRAINT "ProductType_updatedByUserId_fkey";
-- DropForeignKey
ALTER TABLE "Service" DROP CONSTRAINT "Service_productTypeId_fkey";
-- AlterTable
ALTER TABLE "Product" DROP COLUMN "productTypeId",
ADD COLUMN "expenseType" TEXT,
ADD COLUMN "productGroupId" TEXT,
ADD COLUMN "vatIncluded" BOOLEAN;
-- AlterTable
ALTER TABLE "Service" DROP COLUMN "productTypeId",
ADD COLUMN "productGroupId" TEXT;
-- DropTable
DROP TABLE "ProductType";
-- AddForeignKey
ALTER TABLE "Product" ADD CONSTRAINT "Product_productGroupId_fkey" FOREIGN KEY ("productGroupId") REFERENCES "ProductGroup"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Service" ADD CONSTRAINT "Service_productGroupId_fkey" FOREIGN KEY ("productGroupId") REFERENCES "ProductGroup"("id") ON DELETE SET NULL ON UPDATE CASCADE;