168 lines
4 KiB
Text
168 lines
4 KiB
Text
generator zod {
|
|
provider = "zod-prisma-types"
|
|
}
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgres"
|
|
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?
|
|
access_token String?
|
|
expires_at Int?
|
|
ext_expires_in Int?
|
|
token_type String?
|
|
scope String?
|
|
id_token String?
|
|
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?
|
|
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 GameState {
|
|
lobby
|
|
starting
|
|
running
|
|
ended
|
|
aborted
|
|
}
|
|
|
|
model Game {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
state GameState @default(lobby)
|
|
allowSpectators Boolean @default(true)
|
|
allowSpecials Boolean @default(true)
|
|
allowChat Boolean @default(true)
|
|
allowMarkDraw Boolean @default(true)
|
|
gamePin Gamepin?
|
|
users User_Game[]
|
|
}
|
|
|
|
model Gamepin {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
pin String @unique
|
|
gameId String @unique
|
|
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
enum Orientation {
|
|
h
|
|
v
|
|
}
|
|
|
|
model Ship {
|
|
id String @id @default(cuid())
|
|
size Int
|
|
variant Int
|
|
x Int
|
|
y Int
|
|
orientation Orientation
|
|
user_GameId String
|
|
User_Game User_Game @relation(fields: [user_GameId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model Hit {
|
|
id String @id @default(cuid())
|
|
x Int
|
|
y Int
|
|
hit Boolean
|
|
user_GameId String
|
|
User_Game User_Game @relation(fields: [user_GameId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model User_Game {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
gameId String
|
|
userId String
|
|
index Int
|
|
moves Move[]
|
|
ships Ship[]
|
|
hits Hit[]
|
|
chats Chat[]
|
|
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
@@unique([gameId, index])
|
|
@@unique([gameId, userId])
|
|
}
|
|
|
|
enum MoveType {
|
|
missile
|
|
vtorpedo
|
|
htorpedo
|
|
radar
|
|
}
|
|
|
|
model Move {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
index Int
|
|
type MoveType
|
|
x Int
|
|
y Int
|
|
orientation Orientation
|
|
user_game_id String
|
|
user_game User_Game @relation(fields: [user_game_id], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model Chat {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
message String?
|
|
event String?
|
|
user_game_id String
|
|
user_game User_Game @relation(fields: [user_game_id], references: [id], onDelete: Cascade)
|
|
}
|