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 {
|
datasource db {
|
||||||
provider = "mongodb"
|
provider = "mysql"
|
||||||
url = env("DATABASE_URL")
|
url = env("DATABASE_URL")
|
||||||
}
|
}
|
||||||
|
|
||||||
model Player {
|
model Player {
|
||||||
id String @id @default(auto()) @map("_id") @db.ObjectId
|
id String @id @default(cuid())
|
||||||
uuid String @unique @default(uuid())
|
createdAt DateTime @default(now())
|
||||||
createdAt DateTime @default(now())
|
updatedAt DateTime @updatedAt
|
||||||
updatedAt DateTime @updatedAt
|
anonymous Boolean @default(true)
|
||||||
anonymous Boolean @default(true)
|
username String? @unique
|
||||||
username String @unique @default("")
|
email String? @unique
|
||||||
email String @unique @default("")
|
passwordHash String? @unique
|
||||||
passwordHash String @unique @default("")
|
|
||||||
games Game[] @relation(fields: [gameIds], references: [id])
|
|
||||||
gameIds String[] @db.ObjectId
|
|
||||||
tokens Token[]
|
tokens Token[]
|
||||||
|
games Player_Game[]
|
||||||
}
|
}
|
||||||
|
|
||||||
enum TokenType {
|
enum TokenType {
|
||||||
|
@ -27,52 +25,67 @@ enum TokenType {
|
||||||
}
|
}
|
||||||
|
|
||||||
model Token {
|
model Token {
|
||||||
id String @id @default(auto()) @map("_id") @db.ObjectId
|
id String @id @default(cuid())
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
expires DateTime @updatedAt
|
|
||||||
owner Player @relation(fields: [ownerId], references: [id])
|
|
||||||
ownerId String @db.ObjectId
|
|
||||||
token String @unique
|
token String @unique
|
||||||
type TokenType
|
type TokenType
|
||||||
used Boolean @default(false)
|
used Boolean @default(false)
|
||||||
|
ownerId String
|
||||||
|
owner Player @relation(fields: [ownerId], references: [id])
|
||||||
|
Socket Socket?
|
||||||
}
|
}
|
||||||
|
|
||||||
model Game {
|
model Game {
|
||||||
id String @id @default(auto()) @map("_id") @db.ObjectId
|
id String @id @default(cuid())
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
players Player[] @relation(fields: [playerIds], references: [id])
|
running Boolean @default(true)
|
||||||
playerIds String[] @db.ObjectId
|
pin Gamepin?
|
||||||
running Boolean @default(true)
|
players Player_Game[]
|
||||||
Move Move[]
|
}
|
||||||
Gamepin Gamepin[]
|
|
||||||
Chat Chat[]
|
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 {
|
model Move {
|
||||||
id String @id @default(auto()) @map("_id") @db.ObjectId
|
id String @id @default(cuid())
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
// updatedAt DateTime @updatedAt
|
|
||||||
index Int
|
index Int
|
||||||
game Game @relation(fields: [gameId], references: [id])
|
gameId String
|
||||||
gameId String @db.ObjectId
|
game Player_Game @relation(fields: [gameId], references: [id])
|
||||||
}
|
}
|
||||||
|
|
||||||
model Gamepin {
|
model Gamepin {
|
||||||
id String @id @default(auto()) @map("_id") @db.ObjectId
|
id String @id @default(cuid())
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
// updatedAt DateTime @updatedAt
|
|
||||||
pin Int @unique
|
pin Int @unique
|
||||||
|
gameId String @unique
|
||||||
game Game @relation(fields: [gameId], references: [id])
|
game Game @relation(fields: [gameId], references: [id])
|
||||||
gameId String @db.ObjectId
|
|
||||||
}
|
}
|
||||||
|
|
||||||
model Chat {
|
model Chat {
|
||||||
id String @id @default(auto()) @map("_id") @db.ObjectId
|
id String @id @default(cuid())
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
// updatedAt DateTime @updatedAt
|
message String?
|
||||||
message String @default("")
|
event String?
|
||||||
event String @default("")
|
gameId String
|
||||||
game Game @relation(fields: [gameId], references: [id])
|
game Player_Game @relation(fields: [gameId], references: [id])
|
||||||
gameId String @db.ObjectId
|
}
|
||||||
|
|
||||||
|
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