-- CreateTable
CREATE TABLE "FinalGrade" (
    "id" TEXT NOT NULL,
    "userId" TEXT NOT NULL,
    "classId" TEXT NOT NULL,
    "grade" TEXT NOT NULL,
    "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateIndex
CREATE INDEX "FinalGrade_userId_idx" ON "FinalGrade"("userId");

-- CreateIndex
CREATE INDEX "FinalGrade_classId_idx" ON "FinalGrade"("classId");

-- CreateIndex
CREATE UNIQUE INDEX "FinalGrade_userId_classId_key" ON "FinalGrade"("userId", "classId");

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

-- AddForeignKey
ALTER TABLE "FinalGrade" ADD CONSTRAINT "FinalGrade_classId_fkey" FOREIGN KEY ("classId") REFERENCES "Class"("id") ON DELETE CASCADE ON UPDATE CASCADE;
