project-knedita/prisma/migrations/20230725193554_created_notifications_model/migration.sql

20 lines
760 B
SQL

-- CreateEnum
CREATE TYPE "NotificationType" AS ENUM ('WARNING', 'FRIEND');
-- CreateTable
CREATE TABLE "Notifications" (
"id" TEXT NOT NULL,
"type" "NotificationType" NOT NULL,
"content" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"fromUserId" TEXT NOT NULL,
"toUserId" TEXT NOT NULL,
CONSTRAINT "Notifications_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "Notifications" ADD CONSTRAINT "Notifications_fromUserId_fkey" FOREIGN KEY ("fromUserId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Notifications" ADD CONSTRAINT "Notifications_toUserId_fkey" FOREIGN KEY ("toUserId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;