project-knedita/prisma/migrations/20230728124920_created_comment_like_model/migration.sql

60 lines
2 KiB
MySQL
Raw Permalink Normal View History

/*
Warnings:
- The values [FRIEND] on the enum `NotificationType` will be removed. If these variants are still used in the database, this will fail.
- You are about to drop the `Like` table. If the table is not empty, all the data it contains will be lost.
*/
-- AlterEnum
BEGIN;
CREATE TYPE "NotificationType_new" AS ENUM ('WARNING', 'INFO');
ALTER TABLE "Notifications" ALTER COLUMN "type" TYPE "NotificationType_new" USING ("type"::text::"NotificationType_new");
ALTER TYPE "NotificationType" RENAME TO "NotificationType_old";
ALTER TYPE "NotificationType_new" RENAME TO "NotificationType";
DROP TYPE "NotificationType_old";
COMMIT;
-- DropForeignKey
ALTER TABLE "Like" DROP CONSTRAINT "CommentLikes";
-- DropForeignKey
ALTER TABLE "Like" DROP CONSTRAINT "Like_userId_fkey";
-- DropForeignKey
ALTER TABLE "Like" DROP CONSTRAINT "PostLikes";
-- DropTable
DROP TABLE "Like";
-- CreateTable
CREATE TABLE "PostLike" (
"id" TEXT NOT NULL,
"postId" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "PostLike_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "CommentLike" (
"id" TEXT NOT NULL,
"commentId" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "CommentLike_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "PostLike" ADD CONSTRAINT "PostLike_postId_fkey" FOREIGN KEY ("postId") REFERENCES "Post"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "PostLike" ADD CONSTRAINT "PostLike_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "CommentLike" ADD CONSTRAINT "CommentLike_commentId_fkey" FOREIGN KEY ("commentId") REFERENCES "Comments"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "CommentLike" ADD CONSTRAINT "CommentLike_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;