Reworked Prisma schema with mysql usage
This commit is contained in:
parent
da9337a50b
commit
a61b423609
1 changed files with 52 additions and 39 deletions
|
@ -3,22 +3,20 @@ generator client {
|
|||
}
|
||||
|
||||
datasource db {
|
||||
provider = "mongodb"
|
||||
provider = "mysql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model Player {
|
||||
id String @id @default(auto()) @map("_id") @db.ObjectId
|
||||
uuid String @unique @default(uuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
anonymous Boolean @default(true)
|
||||
username String @unique @default("")
|
||||
email String @unique @default("")
|
||||
passwordHash String @unique @default("")
|
||||
games Game[] @relation(fields: [gameIds], references: [id])
|
||||
gameIds String[] @db.ObjectId
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
anonymous Boolean @default(true)
|
||||
username String? @unique
|
||||
email String? @unique
|
||||
passwordHash String? @unique
|
||||
tokens Token[]
|
||||
games Player_Game[]
|
||||
}
|
||||
|
||||
enum TokenType {
|
||||
|
@ -27,52 +25,67 @@ enum TokenType {
|
|||
}
|
||||
|
||||
model Token {
|
||||
id String @id @default(auto()) @map("_id") @db.ObjectId
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
expires DateTime @updatedAt
|
||||
owner Player @relation(fields: [ownerId], references: [id])
|
||||
ownerId String @db.ObjectId
|
||||
token String @unique
|
||||
type TokenType
|
||||
used Boolean @default(false)
|
||||
ownerId String
|
||||
owner Player @relation(fields: [ownerId], references: [id])
|
||||
Socket Socket?
|
||||
}
|
||||
|
||||
model Game {
|
||||
id String @id @default(auto()) @map("_id") @db.ObjectId
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
players Player[] @relation(fields: [playerIds], references: [id])
|
||||
playerIds String[] @db.ObjectId
|
||||
running Boolean @default(true)
|
||||
Move Move[]
|
||||
Gamepin Gamepin[]
|
||||
Chat Chat[]
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
running Boolean @default(true)
|
||||
pin Gamepin?
|
||||
players Player_Game[]
|
||||
}
|
||||
|
||||
model Player_Game {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
gameId String
|
||||
playerId String
|
||||
isOwner Boolean
|
||||
moves Move[]
|
||||
chats Chat[]
|
||||
game Game @relation(fields: [gameId], references: [id])
|
||||
player Player @relation(fields: [playerId], references: [id])
|
||||
|
||||
@@unique([gameId, playerId])
|
||||
}
|
||||
|
||||
model Move {
|
||||
id String @id @default(auto()) @map("_id") @db.ObjectId
|
||||
createdAt DateTime @default(now())
|
||||
// updatedAt DateTime @updatedAt
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
index Int
|
||||
game Game @relation(fields: [gameId], references: [id])
|
||||
gameId String @db.ObjectId
|
||||
gameId String
|
||||
game Player_Game @relation(fields: [gameId], references: [id])
|
||||
}
|
||||
|
||||
model Gamepin {
|
||||
id String @id @default(auto()) @map("_id") @db.ObjectId
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
// updatedAt DateTime @updatedAt
|
||||
pin Int @unique
|
||||
gameId String @unique
|
||||
game Game @relation(fields: [gameId], references: [id])
|
||||
gameId String @db.ObjectId
|
||||
}
|
||||
|
||||
model Chat {
|
||||
id String @id @default(auto()) @map("_id") @db.ObjectId
|
||||
createdAt DateTime @default(now())
|
||||
// updatedAt DateTime @updatedAt
|
||||
message String @default("")
|
||||
event String @default("")
|
||||
game Game @relation(fields: [gameId], references: [id])
|
||||
gameId String @db.ObjectId
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
message String?
|
||||
event String?
|
||||
gameId String
|
||||
game Player_Game @relation(fields: [gameId], references: [id])
|
||||
}
|
||||
|
||||
model Socket {
|
||||
sessionId String @id
|
||||
createdAt DateTime @default(now())
|
||||
tokenId String @unique
|
||||
token Token @relation(fields: [tokenId], references: [id])
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue