diff --git a/prisma/migrations/20240827022454_notification_nickname/migration.sql b/prisma/migrations/20240827022454_notification_nickname/migration.sql new file mode 100644 index 0000000..18c4193 --- /dev/null +++ b/prisma/migrations/20240827022454_notification_nickname/migration.sql @@ -0,0 +1,60 @@ +-- DropForeignKey +ALTER TABLE "UserRoom" DROP CONSTRAINT "UserRoom_roomId_fkey"; + +-- AlterTable +ALTER TABLE "UserRoom" ADD COLUMN "nickname" TEXT; + +-- CreateTable +CREATE TABLE "Board" ( + "id" TEXT NOT NULL, + "roomId" TEXT NOT NULL, + "reveal" BOOLEAN NOT NULL DEFAULT false, + + CONSTRAINT "Board_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Player" ( + "id" TEXT NOT NULL, + "nickname" TEXT NOT NULL, + "imageUrl" TEXT, + "email" TEXT NOT NULL, + "choice" TEXT, + "boardId" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "Player_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Notification" ( + "id" TEXT NOT NULL, + "targetId" TEXT NOT NULL, + "senderId" TEXT NOT NULL, + "boardId" TEXT NOT NULL, + "sound" TEXT NOT NULL, + + CONSTRAINT "Notification_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "Board_roomId_key" ON "Board"("roomId"); + +-- AddForeignKey +ALTER TABLE "UserRoom" ADD CONSTRAINT "UserRoom_roomId_fkey" FOREIGN KEY ("roomId") REFERENCES "Room"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Board" ADD CONSTRAINT "Board_roomId_fkey" FOREIGN KEY ("roomId") REFERENCES "Room"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Player" ADD CONSTRAINT "Player_boardId_fkey" FOREIGN KEY ("boardId") REFERENCES "Board"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Notification" ADD CONSTRAINT "Notification_targetId_fkey" FOREIGN KEY ("targetId") REFERENCES "Player"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Notification" ADD CONSTRAINT "Notification_senderId_fkey" FOREIGN KEY ("senderId") REFERENCES "Player"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Notification" ADD CONSTRAINT "Notification_boardId_fkey" FOREIGN KEY ("boardId") REFERENCES "Board"("id") ON DELETE CASCADE ON UPDATE CASCADE;