Rename "user" column in beerPostLikes, add ERD gen

This commit is contained in:
Aaron William Po
2023-02-13 17:05:00 -05:00
parent 249bfdaf5a
commit ea516e91b5
11 changed files with 2885 additions and 19 deletions

1
prisma/ERD.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 104 KiB

View File

@@ -0,0 +1,16 @@
/*
Warnings:
- You are about to drop the column `userId` on the `BeerPostLike` table. All the data in the column will be lost.
- Added the required column `likedById` to the `BeerPostLike` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE "BeerPostLike" DROP CONSTRAINT "BeerPostLike_userId_fkey";
-- AlterTable
ALTER TABLE "BeerPostLike" DROP COLUMN "userId",
ADD COLUMN "likedById" TEXT NOT NULL;
-- AddForeignKey
ALTER TABLE "BeerPostLike" ADD CONSTRAINT "BeerPostLike_likedById_fkey" FOREIGN KEY ("likedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@@ -5,6 +5,13 @@ generator client {
provider = "prisma-client-js"
}
generator erdSVG {
provider = "prisma-erd-generator"
output = "./ERD.svg"
includeRelationFromFields = true
theme = "neutral"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
@@ -53,8 +60,8 @@ model BeerPostLike {
id String @id @default(uuid())
beerPost BeerPost @relation(fields: [beerPostId], references: [id], onDelete: Cascade)
beerPostId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String
likedBy User @relation(fields: [likedById], references: [id], onDelete: Cascade)
likedById String
createdAt DateTime @default(now()) @db.Timestamptz(3)
updatedAt DateTime? @updatedAt @db.Timestamptz(3)
}

View File

@@ -22,7 +22,7 @@ const createNewBeerPostLikes = async ({
DBClient.instance.beerPostLike.create({
data: {
beerPost: { connect: { id: beerPost.id } },
user: { connect: { id: user.id } },
likedBy: { connect: { id: user.id } },
},
}),
);