russ_react_server/prisma/schema.prisma

105 lines
2.5 KiB
Plaintext

generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @id @default(uuid())
email String @unique
password String
displayName String
avatarUrl String
bio String?
isAdmin Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
permissions Json
order Int @default(0)
Author Author?
}
enum AuthorRole {
WRITER
PHOTOGRAPHER
EDITOR
TRANSLATOR
}
model Author {
id String @id @default(uuid())
displayName String
bio String?
avatarUrl String
order Int @default(0)
okUrl String?
vkUrl String?
websiteUrl String?
email String?
userId String? @unique
user User? @relation(fields: [userId], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
isActive Boolean @default(true)
roles AuthorRole[] @default([])
articles ArticleAuthor[]
}
model Article {
id String @id @default(uuid())
importId Int @default(0)
title String
excerpt String
content String
categoryId Int
cityId Int
coverImage String
readTime Int
likes Int @default(0)
dislikes Int @default(0)
publishedAt DateTime @default(now())
gallery GalleryImage[]
isActive Boolean @default(false)
authors ArticleAuthor[]
}
model ArticleAuthor {
articleId String
authorId String
role AuthorRole
article Article @relation(fields: [articleId], references: [id], onDelete: Cascade)
author Author @relation(fields: [authorId], references: [id], onDelete: Cascade)
@@id([articleId, authorId, role])
}
model GalleryImage {
id String @id @default(uuid())
url String
caption String
alt String
width Int
height Int
size Int
format String
article Article @relation(fields: [articleId], references: [id], onDelete: Cascade)
articleId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
order Int @default(0)
}
model UserReaction {
id String @id @default(uuid())
userId String
articleId String
reaction String // 'like' or 'dislike'
createdAt DateTime @default(now())
@@unique([userId, articleId])
}