datasource db {
provider = "mysql"
url = env("DATABASE_URL")
relationMode = "prisma"
}
generator client {
provider = "prisma-client-js"
}
model Post {
id String @id @default(cuid())
title DateTime @default(now())
content String? @db.VarChar(255)
authorId String
author Like @relation(fields: [authorId], references: [id])
likes Like[]
comments Comment[]
@@index([authorId])
}
model Like {
id String @id @default(cuid())
userId String
postId String
post Post @relation(fields: [postId], references: [id])
@@unique([userId, postId])
}
model Comment {
id String @id @default(cuid())
content String
authorId String
postId String
parentId String?
createdAt DateTime @default(now())
author Post @relation(fields: [authorId], references: [id])
post Post @relation(fields: [postId], references: [id])
parent Comment? @relation("CommentToComment", fields: [parentId])
children Comment[] @relation("CommentToComment")
@@relation("CommentToComment", onDelete: NoAction, onUpdate: NoAction)
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
relationMode = "prisma"
}
generator client {
provider = "prisma-client-js"
}
model Post {
id String @id @default(cuid())
title DateTime @default(now())
content String? @db.VarChar(255)
authorId String
author Like @relation(fields: [authorId], references: [id])
likes Like[]
comments Comment[]
@@index([authorId])
}
model Like {
id String @id @default(cuid())
userId String
postId String
post Post @relation(fields: [postId], references: [id])
@@unique([userId, postId])
}
model Comment {
id String @id @default(cuid())
content String
authorId String
postId String
parentId String?
createdAt DateTime @default(now())
author Post @relation(fields: [authorId], references: [id])
post Post @relation(fields: [postId], references: [id])
parent Comment? @relation("CommentToComment", fields: [parentId])
children Comment[] @relation("CommentToComment")
@@relation("CommentToComment", onDelete: NoAction, onUpdate: NoAction)
}