262 lines
7.4 KiB
Plaintext
262 lines
7.4 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model User {
|
|
id Int @id @default(autoincrement())
|
|
email String @unique
|
|
username String @default("")
|
|
createdAt DateTime @default(now())
|
|
ratingStars RatingStar[]
|
|
reports Report[]
|
|
sessions Session[]
|
|
userPolls UserPoll[]
|
|
userRatings UserRating[]
|
|
reviews Review[]
|
|
reviewVotes ReviewVote[]
|
|
}
|
|
|
|
model Tag {
|
|
id Int @id @default(autoincrement())
|
|
name String
|
|
color String
|
|
ratingTypeId Int
|
|
ratings RatingTag[]
|
|
ratingType RatingType @relation(fields: [ratingTypeId], references: [id])
|
|
}
|
|
|
|
model RatingTag {
|
|
ratingId Int
|
|
tagId Int
|
|
rating Rating @relation(fields: [ratingId], references: [id], onDelete: Cascade)
|
|
tag Tag @relation(fields: [tagId], references: [id], onDelete: Cascade)
|
|
|
|
@@id([ratingId, tagId])
|
|
}
|
|
|
|
model AnonymousRatingVote {
|
|
id Int @id @default(autoincrement())
|
|
ip String
|
|
ratingId Int
|
|
ratingCategoryId Int
|
|
score Int
|
|
createdAt DateTime @default(now())
|
|
ratingCategory RatingCategory @relation(fields: [ratingCategoryId], references: [id])
|
|
rating Rating @relation(fields: [ratingId], references: [id])
|
|
|
|
@@unique([ip, ratingId, ratingCategoryId])
|
|
}
|
|
|
|
model RatingType {
|
|
id Int @id @default(autoincrement())
|
|
name String @unique
|
|
sortOrder Int @default(0)
|
|
hasAttachments Boolean @default(false)
|
|
Header Header[]
|
|
ratings Rating[]
|
|
categories RatingCategory[]
|
|
tags Tag[]
|
|
}
|
|
|
|
model Rating {
|
|
id Int @id @default(autoincrement())
|
|
ratingTypeId Int
|
|
sortOrder Int @default(0)
|
|
name String
|
|
picture String[]
|
|
description String
|
|
icon String
|
|
attachments String @default("")
|
|
headerId Int?
|
|
anonVotes AnonymousRatingVote[]
|
|
Header Header? @relation(fields: [headerId], references: [id])
|
|
ratingType RatingType @relation(fields: [ratingTypeId], references: [id])
|
|
stars RatingStar[]
|
|
tags RatingTag[]
|
|
userRatings UserRating[]
|
|
reviews Review[]
|
|
}
|
|
|
|
model RatingCategory {
|
|
id Int @id @default(autoincrement())
|
|
ratingTypeId Int
|
|
name String
|
|
anonVotes AnonymousRatingVote[]
|
|
ratingType RatingType @relation(fields: [ratingTypeId], references: [id])
|
|
RatingStar RatingStar[]
|
|
userRatings UserRating[]
|
|
}
|
|
|
|
model UserRating {
|
|
id Int @id @default(autoincrement())
|
|
userId Int
|
|
ratingId Int
|
|
ratingCategoryId Int
|
|
score Int
|
|
createdAt DateTime @default(now())
|
|
ratingCategory RatingCategory @relation(fields: [ratingCategoryId], references: [id])
|
|
rating Rating @relation(fields: [ratingId], references: [id])
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
@@unique([userId, ratingId, ratingCategoryId])
|
|
}
|
|
|
|
model RatingStar {
|
|
id Int @id @default(autoincrement())
|
|
userId Int
|
|
ratingId Int
|
|
ratingCategoryId Int
|
|
RatingCategory RatingCategory @relation(fields: [ratingCategoryId], references: [id])
|
|
rating Rating @relation(fields: [ratingId], references: [id])
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
@@unique([userId, ratingId, ratingCategoryId])
|
|
}
|
|
|
|
model Report {
|
|
id Int @id @default(autoincrement())
|
|
userId Int
|
|
subject String
|
|
text String
|
|
createdAt DateTime @default(now())
|
|
user User @relation(fields: [userId], references: [id])
|
|
}
|
|
|
|
model IpAccount {
|
|
ip String @id
|
|
count Int @default(0)
|
|
}
|
|
|
|
model AnonymousPollVote {
|
|
id Int @id @default(autoincrement())
|
|
ip String
|
|
pollEntryId Int
|
|
amount Int
|
|
pollEntry PollEntry @relation(fields: [pollEntryId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([ip, pollEntryId])
|
|
}
|
|
|
|
model PollCategory {
|
|
id Int @id @default(autoincrement())
|
|
name String @unique
|
|
polls Poll[] @relation("PollToCategory")
|
|
}
|
|
|
|
model PollTag {
|
|
id Int @id @default(autoincrement())
|
|
name String
|
|
color String
|
|
image String @default("")
|
|
polls PollToTag[]
|
|
}
|
|
|
|
model PollToTag {
|
|
pollId Int
|
|
tagId Int
|
|
poll Poll @relation(fields: [pollId], references: [id], onDelete: Cascade)
|
|
tag PollTag @relation(fields: [tagId], references: [id], onDelete: Cascade)
|
|
|
|
@@id([pollId, tagId])
|
|
}
|
|
|
|
model Poll {
|
|
id Int @id @default(autoincrement())
|
|
name String
|
|
description String
|
|
image String @default("")
|
|
completed Boolean @default(false)
|
|
resultEntryId Int?
|
|
categoryId Int?
|
|
category PollCategory? @relation("PollToCategory", fields: [categoryId], references: [id])
|
|
entries PollEntry[]
|
|
tags PollToTag[]
|
|
}
|
|
|
|
model PollEntry {
|
|
id Int @id @default(autoincrement())
|
|
pollId Int
|
|
option String
|
|
amount Int @default(0)
|
|
supporters Int @default(0)
|
|
anonPolls AnonymousPollVote[]
|
|
poll Poll @relation(fields: [pollId], references: [id], onDelete: Cascade)
|
|
userPolls UserPoll[]
|
|
}
|
|
|
|
model SiteUpdate {
|
|
id Int @id @default(autoincrement())
|
|
title String
|
|
text String
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model RandomMessage {
|
|
id Int @id @default(autoincrement())
|
|
text String
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model UserPoll {
|
|
id Int @id @default(autoincrement())
|
|
userId Int
|
|
pollEntryId Int
|
|
amount Int
|
|
pollEntry PollEntry @relation(fields: [pollEntryId], references: [id], onDelete: Cascade)
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
@@unique([userId, pollEntryId])
|
|
}
|
|
|
|
model Session {
|
|
id Int @id @default(autoincrement())
|
|
token String @unique
|
|
userId Int
|
|
expiresAt DateTime
|
|
createdAt DateTime @default(now())
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model Header {
|
|
id Int @id @default(autoincrement())
|
|
name String
|
|
sortOrder Int @default(0)
|
|
ratingTypeId Int
|
|
icon String @default("")
|
|
parentId Int?
|
|
Header Header? @relation("HeaderToHeader", fields: [parentId], references: [id])
|
|
other_Header Header[] @relation("HeaderToHeader")
|
|
RatingType RatingType @relation(fields: [ratingTypeId], references: [id], onDelete: Cascade)
|
|
Rating Rating[]
|
|
}
|
|
|
|
model Review {
|
|
id Int @id @default(autoincrement())
|
|
userId Int
|
|
user User @relation(fields: [userId], references: [id])
|
|
ratingId Int
|
|
rating Rating @relation(fields: [ratingId], references: [id])
|
|
subject String
|
|
description String
|
|
createdAt DateTime @default(now())
|
|
votes ReviewVote[]
|
|
|
|
@@unique([userId, ratingId])
|
|
}
|
|
|
|
model ReviewVote {
|
|
id Int @id @default(autoincrement())
|
|
userId Int
|
|
user User @relation(fields: [userId], references: [id])
|
|
reviewId Int
|
|
review Review @relation(fields: [reviewId], references: [id], onDelete: Cascade)
|
|
value Int
|
|
|
|
@@unique([userId, reviewId])
|
|
}
|