81 lines
2.1 KiB
Plaintext
81 lines
2.1 KiB
Plaintext
|
generator client {
|
||
|
provider = "prisma-client-js"
|
||
|
}
|
||
|
|
||
|
datasource db {
|
||
|
provider = "postgresql"
|
||
|
url = env("DATABASE_URL")
|
||
|
}
|
||
|
|
||
|
model User {
|
||
|
id Int @id @default(autoincrement())
|
||
|
name String @unique
|
||
|
money Int @default(0)
|
||
|
currentRunner Boolean @default(false)
|
||
|
actions ChallengeAction[]
|
||
|
geolocations Geolocation[]
|
||
|
moneyUpdates MoneyUpdate[]
|
||
|
trips TrainTrip[]
|
||
|
}
|
||
|
|
||
|
model Geolocation {
|
||
|
id Int @id @default(autoincrement())
|
||
|
userId Int
|
||
|
longitude Float
|
||
|
latitude Float
|
||
|
timestamp DateTime
|
||
|
user User @relation(fields: [userId], references: [id])
|
||
|
}
|
||
|
|
||
|
model Challenge {
|
||
|
id Int @id @default(autoincrement())
|
||
|
title String @unique
|
||
|
description String
|
||
|
reward Int
|
||
|
action ChallengeAction?
|
||
|
}
|
||
|
|
||
|
model ChallengeAction {
|
||
|
id Int @id @default(autoincrement())
|
||
|
userId Int
|
||
|
challengeId Int @unique
|
||
|
active Boolean @default(false)
|
||
|
success Boolean @default(false)
|
||
|
challenge Challenge @relation(fields: [challengeId], references: [id])
|
||
|
user User @relation(fields: [userId], references: [id])
|
||
|
moneyUpdate MoneyUpdate?
|
||
|
}
|
||
|
|
||
|
model TrainTrip {
|
||
|
id String @id
|
||
|
userId Int
|
||
|
distance Float
|
||
|
from String
|
||
|
to String
|
||
|
departureTime DateTime
|
||
|
arrivalTime DateTime
|
||
|
infoJson Json
|
||
|
geometry String
|
||
|
moneyUpdate MoneyUpdate?
|
||
|
user User @relation(fields: [userId], references: [id])
|
||
|
}
|
||
|
|
||
|
model MoneyUpdate {
|
||
|
id Int @id @default(autoincrement())
|
||
|
userId Int
|
||
|
before Int
|
||
|
after Int
|
||
|
reason MoneyUpdateType
|
||
|
actionId Int? @unique
|
||
|
tripId String? @unique
|
||
|
action ChallengeAction? @relation(fields: [actionId], references: [id])
|
||
|
trip TrainTrip? @relation(fields: [tripId], references: [id])
|
||
|
user User @relation(fields: [userId], references: [id])
|
||
|
}
|
||
|
|
||
|
enum MoneyUpdateType {
|
||
|
START
|
||
|
WIN_CHALLENGE
|
||
|
BUY_TRAIN
|
||
|
}
|