/*
  Warnings:

  - You are about to drop the column `status` on the `organizations` table. All the data in the column will be lost.
  - You are about to drop the `TemplateProduct` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `business_hours` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `organization_subscriptions` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `subscription_packages` table. If the table is not empty, all the data it contains will be lost.

*/
-- DropForeignKey
ALTER TABLE "TemplateProduct" DROP CONSTRAINT "TemplateProduct_organizationId_fkey";

-- DropForeignKey
ALTER TABLE "TemplateProduct" DROP CONSTRAINT "TemplateProduct_templateId_fkey";

-- DropForeignKey
ALTER TABLE "business_hours" DROP CONSTRAINT "business_hours_organizationId_fkey";

-- DropForeignKey
ALTER TABLE "organization_subscriptions" DROP CONSTRAINT "organization_subscriptions_organizationId_fkey";

-- DropForeignKey
ALTER TABLE "organization_subscriptions" DROP CONSTRAINT "organization_subscriptions_subscriptionPackageId_fkey";

-- AlterTable
ALTER TABLE "organizations" DROP COLUMN "status";

-- DropTable
DROP TABLE "TemplateProduct";

-- DropTable
DROP TABLE "business_hours";

-- DropTable
DROP TABLE "organization_subscriptions";

-- DropTable
DROP TABLE "subscription_packages";

-- DropEnum
DROP TYPE "BusinessHourDay";

-- DropEnum
DROP TYPE "BusinessHourStatus";

-- CreateTable
CREATE TABLE "templateProduct" (
    "id" SERIAL NOT NULL,
    "productId" INTEGER NOT NULL,
    "name" TEXT NOT NULL,
    "extraNote" TEXT,
    "badge" TEXT,
    "price" DOUBLE PRECISION,
    "discountPrice" DOUBLE PRECISION,
    "quantity" TEXT,
    "productType" "ProductType" NOT NULL,
    "offerTitle" TEXT,
    "image" TEXT NOT NULL,
    "templateId" INTEGER NOT NULL,
    "organizationId" INTEGER NOT NULL,

    CONSTRAINT "templateProduct_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "templateProduct_organizationId_idx" ON "templateProduct"("organizationId");

-- CreateIndex
CREATE INDEX "templateProduct_templateId_idx" ON "templateProduct"("templateId");

-- CreateIndex
CREATE UNIQUE INDEX "templateProduct_organizationId_key" ON "templateProduct"("organizationId");

-- CreateIndex
CREATE UNIQUE INDEX "templateProduct_templateId_key" ON "templateProduct"("templateId");

-- CreateIndex
CREATE INDEX "products_organizationId_name_idx" ON "products"("organizationId", "name");

-- CreateIndex
CREATE INDEX "products_organizationId_slug_idx" ON "products"("organizationId", "slug");

-- CreateIndex
CREATE INDEX "products_organizationId_idx" ON "products"("organizationId");

-- AddForeignKey
ALTER TABLE "templateProduct" ADD CONSTRAINT "templateProduct_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "templates"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "templateProduct" ADD CONSTRAINT "templateProduct_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "organizations"("id") ON DELETE CASCADE ON UPDATE CASCADE;
