2024-12-07 09:17:47 +00:00
|
|
|
generator client {
|
|
|
|
provider = "prisma-client-js"
|
|
|
|
}
|
|
|
|
|
|
|
|
datasource db {
|
|
|
|
provider = "postgresql"
|
|
|
|
url = env("DATABASE_URL")
|
|
|
|
}
|
|
|
|
|
2024-12-08 12:41:37 +00:00
|
|
|
model Player {
|
2024-12-12 20:03:42 +00:00
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
name String @unique
|
|
|
|
password String
|
|
|
|
money Int @default(0)
|
2024-12-14 12:01:11 +00:00
|
|
|
activeChallenge ChallengeAction? @relation("ActiveChallenge", fields: [activeChallengeId], references: [id], onDelete: SetNull)
|
2024-12-12 20:03:42 +00:00
|
|
|
activeChallengeId Int? @unique
|
|
|
|
actions ChallengeAction[]
|
|
|
|
geolocations Geolocation[]
|
|
|
|
moneyUpdates MoneyUpdate[]
|
|
|
|
trips TrainTrip[]
|
|
|
|
runs PlayerRun[]
|
2024-12-08 15:34:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
model Game {
|
2024-12-08 21:37:57 +00:00
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
started Boolean @default(false)
|
2024-12-14 12:01:11 +00:00
|
|
|
currentRun PlayerRun? @relation("CurrentRun", fields: [currentRunId], references: [id], onDelete: SetNull)
|
2024-12-08 21:37:57 +00:00
|
|
|
currentRunId Int? @unique
|
|
|
|
runs PlayerRun[] @relation("GameRuns")
|
|
|
|
}
|
|
|
|
|
|
|
|
model PlayerRun {
|
|
|
|
id Int @id @default(autoincrement())
|
2024-12-14 12:01:11 +00:00
|
|
|
game Game @relation("GameRuns", fields: [gameId], references: [id], onDelete: Cascade)
|
2024-12-08 21:37:57 +00:00
|
|
|
runningGame Game? @relation("CurrentRun")
|
|
|
|
gameId Int
|
2024-12-14 12:01:11 +00:00
|
|
|
runner Player @relation(fields: [runnerId], references: [id], onDelete: Cascade)
|
2024-12-08 21:37:57 +00:00
|
|
|
runnerId Int
|
|
|
|
start DateTime @default(now()) @db.Timestamptz(3)
|
|
|
|
end DateTime? @db.Timestamptz(3)
|
|
|
|
moneyUpdate MoneyUpdate?
|
|
|
|
challengeActions ChallengeAction[]
|
|
|
|
trains TrainTrip[]
|
2024-12-07 09:17:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
model Geolocation {
|
2024-12-07 14:11:47 +00:00
|
|
|
id Int @id @default(autoincrement())
|
2024-12-14 12:01:11 +00:00
|
|
|
player Player @relation(fields: [playerId], references: [id], onDelete: Cascade)
|
2024-12-08 12:41:37 +00:00
|
|
|
playerId Int
|
2024-12-07 14:11:47 +00:00
|
|
|
longitude Float
|
|
|
|
latitude Float
|
|
|
|
speed Float
|
|
|
|
accuracy Float
|
|
|
|
altitude Float
|
|
|
|
altitudeAccuracy Float
|
2024-12-07 20:16:44 +00:00
|
|
|
timestamp DateTime @db.Timestamptz(3)
|
2024-12-07 09:17:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
model Challenge {
|
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
title String @unique
|
|
|
|
description String
|
|
|
|
reward Int
|
|
|
|
action ChallengeAction?
|
|
|
|
}
|
|
|
|
|
|
|
|
model ChallengeAction {
|
2024-12-07 20:11:37 +00:00
|
|
|
id Int @id @default(autoincrement())
|
2024-12-14 12:01:11 +00:00
|
|
|
player Player @relation(fields: [playerId], references: [id], onDelete: Restrict)
|
2024-12-08 12:41:37 +00:00
|
|
|
playerId Int
|
2024-12-14 12:01:11 +00:00
|
|
|
challenge Challenge @relation(fields: [challengeId], references: [id], onDelete: Cascade)
|
2024-12-07 20:11:37 +00:00
|
|
|
challengeId Int @unique
|
|
|
|
success Boolean @default(false)
|
2024-12-07 20:16:44 +00:00
|
|
|
start DateTime @default(now()) @db.Timestamptz(3)
|
|
|
|
end DateTime? @db.Timestamptz(3)
|
|
|
|
penaltyStart DateTime? @db.Timestamptz(3)
|
|
|
|
penaltyEnd DateTime? @db.Timestamptz(3)
|
2024-12-14 12:01:11 +00:00
|
|
|
run PlayerRun @relation(fields: [runId], references: [id], onDelete: Restrict)
|
2024-12-08 21:37:57 +00:00
|
|
|
runId Int
|
2024-12-12 20:03:42 +00:00
|
|
|
activePlayer Player? @relation("ActiveChallenge")
|
2024-12-08 10:39:57 +00:00
|
|
|
moneyUpdate MoneyUpdate?
|
2024-12-07 09:17:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
model TrainTrip {
|
|
|
|
id String @id
|
2024-12-14 12:01:11 +00:00
|
|
|
player Player @relation(fields: [playerId], references: [id], onDelete: Restrict)
|
2024-12-08 12:41:37 +00:00
|
|
|
playerId Int
|
2024-12-07 09:17:47 +00:00
|
|
|
distance Float
|
|
|
|
from String
|
|
|
|
to String
|
2024-12-07 20:16:44 +00:00
|
|
|
departureTime DateTime @db.Timestamptz(3)
|
|
|
|
arrivalTime DateTime @db.Timestamptz(3)
|
2024-12-07 09:17:47 +00:00
|
|
|
infoJson Json
|
2024-12-14 12:01:11 +00:00
|
|
|
run PlayerRun @relation(fields: [runId], references: [id], onDelete: Restrict)
|
2024-12-08 21:37:57 +00:00
|
|
|
runId Int
|
2024-12-07 09:17:47 +00:00
|
|
|
moneyUpdate MoneyUpdate?
|
|
|
|
}
|
|
|
|
|
|
|
|
model MoneyUpdate {
|
2024-12-08 10:39:57 +00:00
|
|
|
id Int @id @default(autoincrement())
|
2024-12-14 12:01:11 +00:00
|
|
|
player Player @relation(fields: [playerId], references: [id], onDelete: Restrict)
|
2024-12-08 12:41:37 +00:00
|
|
|
playerId Int
|
2024-12-08 10:39:57 +00:00
|
|
|
amount Int
|
|
|
|
reason MoneyUpdateType
|
2024-12-14 12:01:11 +00:00
|
|
|
action ChallengeAction? @relation(fields: [actionId], references: [id], onDelete: Cascade)
|
2024-12-08 10:39:57 +00:00
|
|
|
actionId Int? @unique
|
2024-12-14 12:01:11 +00:00
|
|
|
trip TrainTrip? @relation(fields: [tripId], references: [id], onDelete: Cascade)
|
2024-12-08 10:39:57 +00:00
|
|
|
tripId String? @unique
|
2024-12-14 12:01:11 +00:00
|
|
|
run PlayerRun? @relation(fields: [runId], references: [id], onDelete: Cascade)
|
2024-12-08 21:37:57 +00:00
|
|
|
runId Int? @unique
|
2024-12-08 10:39:57 +00:00
|
|
|
timestamp DateTime @default(now()) @db.Timestamptz(3)
|
2024-12-07 09:17:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enum MoneyUpdateType {
|
|
|
|
START
|
2024-12-08 21:37:57 +00:00
|
|
|
NEW_RUN
|
2024-12-14 12:30:26 +00:00
|
|
|
CHALLENGE
|
2024-12-07 09:17:47 +00:00
|
|
|
BUY_TRAIN
|
|
|
|
}
|