/*
  Warnings:

  - You are about to drop the column `turnstileStatus` on the `Dealer` table. All the data in the column will be lost.

*/
-- DropIndex
DROP INDEX "Dealer_customDomain_idx";

-- AlterTable
ALTER TABLE "Dealer" DROP COLUMN "turnstileStatus";

-- CreateTable
CREATE TABLE "ResourceCategory" (
    "id" TEXT NOT NULL,
    "name" TEXT NOT NULL,
    "slug" TEXT NOT NULL,
    "sortOrder" INTEGER NOT NULL DEFAULT 0,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,

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

-- CreateTable
CREATE TABLE "ResourceGuide" (
    "id" TEXT NOT NULL,
    "categoryId" TEXT NOT NULL,
    "slug" TEXT NOT NULL,
    "title" TEXT NOT NULL,
    "puckData" JSONB,
    "status" TEXT NOT NULL DEFAULT 'draft',
    "sortOrder" INTEGER NOT NULL DEFAULT 0,
    "publishedAt" TIMESTAMP(3),
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    "createdBy" TEXT NOT NULL,

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

-- CreateIndex
CREATE UNIQUE INDEX "ResourceCategory_name_key" ON "ResourceCategory"("name");

-- CreateIndex
CREATE UNIQUE INDEX "ResourceCategory_slug_key" ON "ResourceCategory"("slug");

-- CreateIndex
CREATE INDEX "ResourceCategory_sortOrder_idx" ON "ResourceCategory"("sortOrder");

-- CreateIndex
CREATE UNIQUE INDEX "ResourceGuide_slug_key" ON "ResourceGuide"("slug");

-- CreateIndex
CREATE INDEX "ResourceGuide_categoryId_sortOrder_idx" ON "ResourceGuide"("categoryId", "sortOrder");

-- CreateIndex
CREATE INDEX "ResourceGuide_status_idx" ON "ResourceGuide"("status");

-- AddForeignKey
ALTER TABLE "ResourceGuide" ADD CONSTRAINT "ResourceGuide_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "ResourceCategory"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
