mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
283 lines
8.1 KiB
Text
283 lines
8.1 KiB
Text
// This is your Prisma schema file,
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
previewFeatures = ["fullTextSearch", "fullTextIndex"]
|
|
}
|
|
|
|
datasource db {
|
|
provider = "mysql"
|
|
url = env("DATABASE_URL")
|
|
relationMode = "prisma"
|
|
}
|
|
|
|
model Role {
|
|
id String @id @default(cuid())
|
|
name String @unique
|
|
userRoles UserRole[]
|
|
|
|
@@map("roles")
|
|
}
|
|
|
|
model UserRole {
|
|
id String @id @default(cuid())
|
|
user User @relation(fields: [user_id], references: [id])
|
|
user_id String
|
|
role Role @relation(fields: [role_id], references: [id])
|
|
role_id String
|
|
created_at DateTime @default(now()) @db.Timestamp(6)
|
|
updated_at DateTime @updatedAt @db.Timestamp(6)
|
|
|
|
@@unique([user_id, role_id])
|
|
@@index([user_id])
|
|
@@index([role_id])
|
|
@@map("user_roles")
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
username String @unique
|
|
email String? @unique
|
|
firstName String?
|
|
lastName String?
|
|
roles UserRole[]
|
|
verified Boolean @default(false)
|
|
receiveEmail Boolean @default(false)
|
|
token String? @unique
|
|
collection Collection?
|
|
wishlist Wishlist?
|
|
list List[]
|
|
theme String @default("system")
|
|
created_at DateTime @default(now()) @db.Timestamp(6)
|
|
updated_at DateTime @updatedAt @db.Timestamp(6)
|
|
auth_session Session[]
|
|
auth_key Key[]
|
|
|
|
@@map("users")
|
|
}
|
|
|
|
model Session {
|
|
id String @id @unique
|
|
user_id String
|
|
active_expires BigInt
|
|
idle_expires BigInt
|
|
user User @relation(references: [id], fields: [user_id], onDelete: Cascade)
|
|
|
|
@@index([user_id])
|
|
@@map("sessions")
|
|
}
|
|
|
|
model Key {
|
|
id String @id @unique
|
|
hashed_password String?
|
|
user_id String
|
|
user User @relation(references: [id], fields: [user_id], onDelete: Cascade)
|
|
|
|
@@index([user_id])
|
|
@@map("keys")
|
|
}
|
|
|
|
model Collection {
|
|
id String @id @default(cuid())
|
|
user_id String @unique
|
|
user User @relation(references: [id], fields: [user_id])
|
|
items CollectionItem[]
|
|
|
|
@@index([user_id])
|
|
@@map("collections")
|
|
}
|
|
|
|
model CollectionItem {
|
|
id String @id @default(cuid())
|
|
collection_id String
|
|
collection Collection @relation(references: [id], fields: [collection_id], onDelete: Cascade)
|
|
game_id String @unique
|
|
game Game @relation(references: [id], fields: [game_id])
|
|
times_played Int
|
|
|
|
@@index([game_id, collection_id])
|
|
@@index([game_id])
|
|
@@index([collection_id])
|
|
@@map("collection_items")
|
|
}
|
|
|
|
model Wishlist {
|
|
id String @id @default(cuid())
|
|
user_id String @unique
|
|
user User @relation(references: [id], fields: [user_id])
|
|
items WishlistItem[]
|
|
|
|
@@index([user_id])
|
|
@@map("wishlists")
|
|
}
|
|
|
|
model WishlistItem {
|
|
id String @id @default(cuid())
|
|
wishlist_id String
|
|
wishlist Wishlist @relation(references: [id], fields: [wishlist_id], onDelete: Cascade)
|
|
game_id String @unique
|
|
game Game @relation(references: [id], fields: [game_id])
|
|
created_at DateTime @default(now()) @db.Timestamp(6)
|
|
updated_at DateTime @updatedAt @db.Timestamp(6)
|
|
|
|
@@index([game_id, wishlist_id])
|
|
@@index([game_id])
|
|
@@index([wishlist_id])
|
|
@@map("wishlist_items")
|
|
}
|
|
|
|
model List {
|
|
id String @id @default(cuid())
|
|
name String
|
|
user_id String @unique
|
|
user User @relation(references: [id], fields: [user_id])
|
|
items ListItem[]
|
|
|
|
@@index([user_id])
|
|
@@map("lists")
|
|
}
|
|
|
|
model ListItem {
|
|
id String @id @default(cuid())
|
|
list_id String
|
|
list List @relation(references: [id], fields: [list_id], onDelete: Cascade)
|
|
game_id String @unique
|
|
game Game @relation(references: [id], fields: [game_id])
|
|
created_at DateTime @default(now()) @db.Timestamp(6)
|
|
updated_at DateTime @updatedAt @db.Timestamp(6)
|
|
|
|
@@index([game_id, list_id])
|
|
@@index([game_id])
|
|
@@index([list_id])
|
|
@@map("list_items")
|
|
}
|
|
|
|
model Game {
|
|
id String @id @default(cuid())
|
|
name String
|
|
slug String
|
|
description String? @db.LongText
|
|
year_published Int? @db.Year
|
|
min_players Int?
|
|
max_players Int?
|
|
playtime Int?
|
|
min_playtime Int?
|
|
max_playtime Int?
|
|
min_age Int?
|
|
image_url String?
|
|
thumb_url String?
|
|
url String?
|
|
rules_url String?
|
|
categories Category[]
|
|
mechanics Mechanic[]
|
|
designers Designer[]
|
|
publishers Publisher[]
|
|
artists Artist[]
|
|
names GameName[]
|
|
expansions Expansion[] @relation("BaseToExpansion")
|
|
expansion_of Expansion[] @relation("ExpansionToBase")
|
|
collection_items CollectionItem[]
|
|
wishlist_items WishlistItem[]
|
|
list_items ListItem[]
|
|
external_id Int @unique
|
|
last_sync_at DateTime? @db.Timestamp(6)
|
|
created_at DateTime @default(now()) @db.Timestamp(6)
|
|
updated_at DateTime @updatedAt @db.Timestamp(6)
|
|
|
|
@@fulltext([name])
|
|
@@fulltext([slug])
|
|
@@map("games")
|
|
}
|
|
|
|
model GameName {
|
|
id String @id @default(cuid())
|
|
name String
|
|
slug String
|
|
game_id String
|
|
game Game @relation(references: [id], fields: [game_id])
|
|
created_at DateTime @default(now()) @db.Timestamp(6)
|
|
updated_at DateTime @updatedAt @db.Timestamp(6)
|
|
|
|
@@index([game_id])
|
|
@@map("game_names")
|
|
}
|
|
|
|
model Publisher {
|
|
id String @id @default(cuid())
|
|
name String
|
|
slug String
|
|
external_id Int @unique
|
|
games Game[]
|
|
created_at DateTime @default(now()) @db.Timestamp(6)
|
|
updated_at DateTime @updatedAt @db.Timestamp(6)
|
|
|
|
@@fulltext([name])
|
|
@@map("publishers")
|
|
}
|
|
|
|
model Category {
|
|
id String @id @default(cuid())
|
|
name String
|
|
slug String
|
|
games Game[]
|
|
external_id Int @unique
|
|
created_at DateTime @default(now()) @db.Timestamp(6)
|
|
updated_at DateTime @updatedAt @db.Timestamp(6)
|
|
|
|
@@fulltext([name])
|
|
@@map("categories")
|
|
}
|
|
|
|
model Mechanic {
|
|
id String @id @default(cuid())
|
|
name String
|
|
slug String
|
|
games Game[]
|
|
external_id Int @unique
|
|
created_at DateTime @default(now()) @db.Timestamp(6)
|
|
updated_at DateTime @updatedAt @db.Timestamp(6)
|
|
|
|
@@fulltext([name])
|
|
@@map("mechanics")
|
|
}
|
|
|
|
model Designer {
|
|
id String @id @default(cuid())
|
|
name String
|
|
slug String
|
|
external_id Int @unique
|
|
games Game[]
|
|
created_at DateTime @default(now()) @db.Timestamp(6)
|
|
updated_at DateTime @updatedAt @db.Timestamp(6)
|
|
|
|
@@fulltext([name])
|
|
@@map("designers")
|
|
}
|
|
|
|
model Artist {
|
|
id String @id @default(cuid())
|
|
name String
|
|
slug String @unique
|
|
external_id Int @unique
|
|
games Game[]
|
|
created_at DateTime @default(now()) @db.Timestamp(6)
|
|
updated_at DateTime @updatedAt @db.Timestamp(6)
|
|
|
|
@@fulltext([name])
|
|
@@map("artists")
|
|
}
|
|
|
|
model Expansion {
|
|
id String @id @default(cuid())
|
|
base_game Game @relation(name: "BaseToExpansion", fields: [base_game_id], references: [id])
|
|
base_game_id String
|
|
game Game @relation(name: "ExpansionToBase", fields: [game_id], references: [id])
|
|
game_id String
|
|
created_at DateTime @default(now()) @db.Timestamp(6)
|
|
updated_at DateTime @updatedAt @db.Timestamp(6)
|
|
|
|
@@index([base_game_id])
|
|
@@index([game_id])
|
|
@@map("expansions")
|
|
}
|