mirror of
https://github.com/hknsh/project-knedita.git
synced 2024-12-01 10:51:17 +00:00
59 lines
2 KiB
PL/PgSQL
59 lines
2 KiB
PL/PgSQL
/*
|
|
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;
|