Initial commit
This commit is contained in:
commit
b3a51a4115
10336 changed files with 2381973 additions and 0 deletions
128
backend/prisma/schema.prisma
Normal file
128
backend/prisma/schema.prisma
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(uuid())
|
||||
email String @unique
|
||||
passwordHash String
|
||||
name String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
games Game[] @relation("GameMaster")
|
||||
teams TeamMember[]
|
||||
captainOf Team? @relation("TeamCaptain")
|
||||
chatMessages ChatMessage[]
|
||||
}
|
||||
|
||||
model Game {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
description String?
|
||||
prizeDetails String?
|
||||
visibility Visibility @default(PUBLIC)
|
||||
startDate DateTime?
|
||||
locationLat Float?
|
||||
locationLng Float?
|
||||
searchRadius Float?
|
||||
timeLimitPerLeg Int?
|
||||
timeDeductionPenalty Int?
|
||||
status GameStatus @default(DRAFT)
|
||||
inviteCode String? @unique
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
gameMasterId String
|
||||
gameMaster User @relation("GameMaster", fields: [gameMasterId], references: [id])
|
||||
legs Leg[]
|
||||
teams Team[]
|
||||
chatMessages ChatMessage[]
|
||||
}
|
||||
|
||||
model Leg {
|
||||
id String @id @default(uuid())
|
||||
gameId String
|
||||
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
|
||||
sequenceNumber Int
|
||||
description String
|
||||
conditionType String @default("photo")
|
||||
conditionDetails String?
|
||||
locationLat Float?
|
||||
locationLng Float?
|
||||
timeLimit Int?
|
||||
teams Team[]
|
||||
}
|
||||
|
||||
model Team {
|
||||
id String @id @default(uuid())
|
||||
gameId String
|
||||
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
|
||||
name String
|
||||
captainId String? @unique
|
||||
captain User? @relation("TeamCaptain", fields: [captainId], references: [id])
|
||||
currentLegId String?
|
||||
currentLeg Leg? @relation(fields: [currentLegId], references: [id])
|
||||
status TeamStatus @default(ACTIVE)
|
||||
totalTimeDeduction Int @default(0)
|
||||
lat Float?
|
||||
lng Float?
|
||||
rank Int?
|
||||
createdAt DateTime @default(now())
|
||||
members TeamMember[]
|
||||
photoSubmissions PhotoSubmission[]
|
||||
chatMessages ChatMessage[]
|
||||
}
|
||||
|
||||
model TeamMember {
|
||||
id String @id @default(uuid())
|
||||
teamId String
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
joinedAt DateTime @default(now())
|
||||
|
||||
@@unique([teamId, userId])
|
||||
}
|
||||
|
||||
model PhotoSubmission {
|
||||
id String @id @default(uuid())
|
||||
teamId String
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
legId String
|
||||
photoUrl String
|
||||
approved Boolean @default(false)
|
||||
submittedAt DateTime @default(now())
|
||||
}
|
||||
|
||||
model ChatMessage {
|
||||
id String @id @default(uuid())
|
||||
gameId String
|
||||
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
|
||||
teamId String?
|
||||
team Team? @relation(fields: [teamId], references: [id])
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
message String
|
||||
sentAt DateTime @default(now())
|
||||
}
|
||||
|
||||
enum Visibility {
|
||||
PUBLIC
|
||||
PRIVATE
|
||||
}
|
||||
|
||||
enum GameStatus {
|
||||
DRAFT
|
||||
LIVE
|
||||
ENDED
|
||||
}
|
||||
|
||||
enum TeamStatus {
|
||||
ACTIVE
|
||||
DISQUALIFIED
|
||||
FINISHED
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue