-- AlterTable
ALTER TABLE "Video" ADD COLUMN     "instantAccess" BOOLEAN NOT NULL DEFAULT false;

-- CreateTable
CREATE TABLE "VideoUnlock" (
    "id" TEXT NOT NULL,
    "userId" TEXT NOT NULL,
    "videoId" TEXT NOT NULL,
    "unlockedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateIndex
CREATE INDEX "VideoUnlock_userId_idx" ON "VideoUnlock"("userId");

-- CreateIndex
CREATE INDEX "VideoUnlock_videoId_idx" ON "VideoUnlock"("videoId");

-- CreateIndex
CREATE INDEX "VideoUnlock_userId_videoId_idx" ON "VideoUnlock"("userId", "videoId");

-- CreateIndex
CREATE UNIQUE INDEX "VideoUnlock_userId_videoId_key" ON "VideoUnlock"("userId", "videoId");

-- AddForeignKey
ALTER TABLE "VideoUnlock" ADD CONSTRAINT "VideoUnlock_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "VideoUnlock" ADD CONSTRAINT "VideoUnlock_videoId_fkey" FOREIGN KEY ("videoId") REFERENCES "Video"("id") ON DELETE CASCADE ON UPDATE CASCADE;
