HotTRDealsBackend/prisma/migrations/20260120163044_seller_naming_change/migration.sql
2026-01-23 17:28:21 +00:00

73 lines
2.5 KiB
SQL

/*
Warnings:
- You are about to drop the column `sellerId` on the `Deal` table. All the data in the column will be lost.
- You are about to drop the column `customCompany` on the `Deal` table. All the data in the column will be lost.
- You are about to drop the `Company` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `CompanyDomain` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "public"."Company" DROP CONSTRAINT "Company_createdById_fkey";
-- DropForeignKey
ALTER TABLE "public"."CompanyDomain" DROP CONSTRAINT "CompanyDomain_sellerId_fkey";
-- DropForeignKey
ALTER TABLE "public"."CompanyDomain" DROP CONSTRAINT "CompanyDomain_createdById_fkey";
-- DropForeignKey
ALTER TABLE "public"."Deal" DROP CONSTRAINT "Deal_sellerId_fkey";
-- AlterTable
ALTER TABLE "Deal" DROP COLUMN "sellerId",
DROP COLUMN "customCompany",
ADD COLUMN "customSeller" TEXT,
ADD COLUMN "sellerId" INTEGER;
-- DropTable
DROP TABLE "public"."Company";
-- DropTable
DROP TABLE "public"."CompanyDomain";
-- CreateTable
CREATE TABLE "SellerDomain" (
"id" SERIAL NOT NULL,
"domain" TEXT NOT NULL,
"sellerId" INTEGER NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"createdById" INTEGER NOT NULL,
CONSTRAINT "SellerDomain_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Seller" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"createdById" INTEGER NOT NULL,
CONSTRAINT "Seller_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "SellerDomain_domain_key" ON "SellerDomain"("domain");
-- CreateIndex
CREATE UNIQUE INDEX "Seller_name_key" ON "Seller"("name");
-- AddForeignKey
ALTER TABLE "SellerDomain" ADD CONSTRAINT "SellerDomain_sellerId_fkey" FOREIGN KEY ("sellerId") REFERENCES "Seller"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "SellerDomain" ADD CONSTRAINT "SellerDomain_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Seller" ADD CONSTRAINT "Seller_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Deal" ADD CONSTRAINT "Deal_sellerId_fkey" FOREIGN KEY ("sellerId") REFERENCES "Seller"("id") ON DELETE SET NULL ON UPDATE CASCADE;