128 lines
3 KiB
Text
128 lines
3 KiB
Text
generator zod {
|
|
provider = "zod-prisma-types"
|
|
}
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "mysql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Account {
|
|
id String @id @default(cuid())
|
|
userId String @map("user_id")
|
|
type String
|
|
provider String
|
|
providerAccountId String @map("provider_account_id")
|
|
refresh_token String? @db.Text
|
|
access_token String? @db.Text
|
|
expires_at Int?
|
|
ext_expires_in Int?
|
|
token_type String?
|
|
scope String?
|
|
id_token String? @db.Text
|
|
session_state String?
|
|
oauth_token_secret String?
|
|
oauth_token String?
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([provider, providerAccountId])
|
|
@@map("accounts")
|
|
}
|
|
|
|
model Session {
|
|
id String @id @default(cuid())
|
|
sessionToken String @unique @map("session_token")
|
|
userId String @map("user_id")
|
|
expires DateTime
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@map("sessions")
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
name String?
|
|
email String? @unique
|
|
emailVerified DateTime? @map("email_verified")
|
|
image String? @db.Text
|
|
createdAt DateTime @default(now()) @map(name: "created_at")
|
|
updatedAt DateTime @updatedAt @map(name: "updated_at")
|
|
games User_Game[]
|
|
accounts Account[]
|
|
sessions Session[]
|
|
|
|
@@map(name: "users")
|
|
}
|
|
|
|
model VerificationToken {
|
|
identifier String
|
|
token String @unique
|
|
expires DateTime
|
|
|
|
@@unique([identifier, token])
|
|
@@map("verificationtokens")
|
|
}
|
|
|
|
enum TokenType {
|
|
REFRESH
|
|
ACCESS
|
|
}
|
|
|
|
enum GameState {
|
|
launching
|
|
running
|
|
ended
|
|
}
|
|
|
|
model Game {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
state GameState @default(launching)
|
|
gamePin Gamepin?
|
|
users User_Game[]
|
|
}
|
|
|
|
model User_Game {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
gameId String
|
|
userId String
|
|
isOwner Boolean
|
|
moves Move[]
|
|
chats Chat[]
|
|
game Game @relation(fields: [gameId], references: [id])
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
@@unique([gameId, userId])
|
|
}
|
|
|
|
model Move {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
index Int
|
|
gameId String
|
|
game User_Game @relation(fields: [gameId], references: [id])
|
|
}
|
|
|
|
model Gamepin {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
pin String @unique
|
|
gameId String @unique
|
|
game Game @relation(fields: [gameId], references: [id])
|
|
}
|
|
|
|
model Chat {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
message String?
|
|
event String?
|
|
gameId String
|
|
game User_Game @relation(fields: [gameId], references: [id])
|
|
}
|