2024-12-07 09:17:47 +00:00
|
|
|
generator client {
|
|
|
|
provider = "prisma-client-js"
|
|
|
|
}
|
|
|
|
|
|
|
|
datasource db {
|
|
|
|
provider = "postgresql"
|
|
|
|
url = env("DATABASE_URL")
|
|
|
|
}
|
|
|
|
|
|
|
|
model User {
|
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
name String @unique
|
2024-12-07 12:06:15 +00:00
|
|
|
password String
|
2024-12-07 09:17:47 +00:00
|
|
|
money Int @default(0)
|
|
|
|
currentRunner Boolean @default(false)
|
|
|
|
actions ChallengeAction[]
|
|
|
|
geolocations Geolocation[]
|
|
|
|
moneyUpdates MoneyUpdate[]
|
|
|
|
trips TrainTrip[]
|
|
|
|
}
|
|
|
|
|
|
|
|
model Geolocation {
|
2024-12-07 14:11:47 +00:00
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
userId Int
|
|
|
|
longitude Float
|
|
|
|
latitude Float
|
|
|
|
speed Float
|
|
|
|
accuracy Float
|
|
|
|
altitude Float
|
|
|
|
altitudeAccuracy Float
|
|
|
|
timestamp DateTime
|
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 {
|
|
|
|
id Int @id @default(autoincrement())
|
2024-12-07 14:11:47 +00:00
|
|
|
user User @relation(fields: [userId], references: [id])
|
2024-12-07 09:17:47 +00:00
|
|
|
userId Int
|
2024-12-07 14:11:47 +00:00
|
|
|
challenge Challenge @relation(fields: [challengeId], references: [id])
|
2024-12-07 09:17:47 +00:00
|
|
|
challengeId Int @unique
|
|
|
|
active Boolean @default(false)
|
|
|
|
success Boolean @default(false)
|
|
|
|
moneyUpdate MoneyUpdate?
|
|
|
|
}
|
|
|
|
|
|
|
|
model TrainTrip {
|
|
|
|
id String @id
|
2024-12-07 14:11:47 +00:00
|
|
|
user User @relation(fields: [userId], references: [id])
|
2024-12-07 09:17:47 +00:00
|
|
|
userId Int
|
|
|
|
distance Float
|
|
|
|
from String
|
|
|
|
to String
|
|
|
|
departureTime DateTime
|
|
|
|
arrivalTime DateTime
|
|
|
|
infoJson Json
|
|
|
|
geometry String
|
|
|
|
moneyUpdate MoneyUpdate?
|
|
|
|
}
|
|
|
|
|
|
|
|
model MoneyUpdate {
|
|
|
|
id Int @id @default(autoincrement())
|
2024-12-07 14:11:47 +00:00
|
|
|
user User @relation(fields: [userId], references: [id])
|
2024-12-07 09:17:47 +00:00
|
|
|
userId Int
|
|
|
|
before Int
|
|
|
|
after Int
|
|
|
|
reason MoneyUpdateType
|
|
|
|
action ChallengeAction? @relation(fields: [actionId], references: [id])
|
2024-12-07 14:11:47 +00:00
|
|
|
actionId Int? @unique
|
2024-12-07 09:17:47 +00:00
|
|
|
trip TrainTrip? @relation(fields: [tripId], references: [id])
|
2024-12-07 14:11:47 +00:00
|
|
|
tripId String? @unique
|
2024-12-07 09:17:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enum MoneyUpdateType {
|
|
|
|
START
|
|
|
|
WIN_CHALLENGE
|
|
|
|
BUY_TRAIN
|
|
|
|
}
|