-- CreateTable
CREATE TABLE "WordFilter" (
    "id" TEXT NOT NULL,
    "word" TEXT NOT NULL,
    "replacement" TEXT NOT NULL,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateTable
CREATE TABLE "ModerationSetting" (
    "id" TEXT NOT NULL,
    "blockNsfw" BOOLEAN NOT NULL DEFAULT false,
    "blurFaces" BOOLEAN NOT NULL DEFAULT false,

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

-- CreateTable
CREATE TABLE "TourRating" (
    "id" TEXT NOT NULL,
    "tourId" TEXT NOT NULL,
    "targetUserId" TEXT NOT NULL,
    "raterUserId" TEXT NOT NULL,
    "honesty" INTEGER NOT NULL DEFAULT 5,
    "transparency" INTEGER NOT NULL DEFAULT 5,
    "enthusiasm" INTEGER NOT NULL DEFAULT 5,
    "cheerfulness" INTEGER NOT NULL DEFAULT 5,
    "seriousness" INTEGER NOT NULL DEFAULT 5,
    "planning" INTEGER NOT NULL DEFAULT 5,
    "survival" INTEGER NOT NULL DEFAULT 5,
    "averageScore" DOUBLE PRECISION NOT NULL DEFAULT 5.0,
    "comment" TEXT,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateTable
CREATE TABLE "TourShare" (
    "id" TEXT NOT NULL,
    "tourId" TEXT NOT NULL,
    "token" TEXT NOT NULL,
    "isEnabled" BOOLEAN NOT NULL DEFAULT true,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateIndex
CREATE UNIQUE INDEX "WordFilter_word_key" ON "WordFilter"("word");

-- CreateIndex
CREATE UNIQUE INDEX "TourRating_tourId_targetUserId_raterUserId_key" ON "TourRating"("tourId", "targetUserId", "raterUserId");

-- CreateIndex
CREATE UNIQUE INDEX "TourShare_tourId_key" ON "TourShare"("tourId");

-- CreateIndex
CREATE UNIQUE INDEX "TourShare_token_key" ON "TourShare"("token");

-- AddForeignKey
ALTER TABLE "TourRating" ADD CONSTRAINT "TourRating_tourId_fkey" FOREIGN KEY ("tourId") REFERENCES "Tour"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "TourRating" ADD CONSTRAINT "TourRating_targetUserId_fkey" FOREIGN KEY ("targetUserId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "TourRating" ADD CONSTRAINT "TourRating_raterUserId_fkey" FOREIGN KEY ("raterUserId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "TourShare" ADD CONSTRAINT "TourShare_tourId_fkey" FOREIGN KEY ("tourId") REFERENCES "Tour"("id") ON DELETE CASCADE ON UPDATE CASCADE;
