traintrape-moi/server/prisma/schema.prisma

96 lines
2.8 KiB
Plaintext
Raw Normal View History

generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
2024-12-08 12:41:37 +00:00
model Player {
id Int @id @default(autoincrement())
name String @unique
2024-12-07 12:06:15 +00:00
password String
money Int @default(0)
actions ChallengeAction[]
geolocations Geolocation[]
moneyUpdates MoneyUpdate[]
trips TrainTrip[]
2024-12-08 15:34:06 +00:00
runningGame Game?
}
model Game {
id Int @id @default(autoincrement())
started Boolean @default(false)
currentRunner Player? @relation(fields: [currentRunnerId], references: [id])
currentRunnerId Int? @unique
}
model Geolocation {
2024-12-07 14:11:47 +00:00
id Int @id @default(autoincrement())
2024-12-08 12:41:37 +00:00
player Player @relation(fields: [playerId], references: [id])
playerId Int
2024-12-07 14:11:47 +00:00
longitude Float
latitude Float
speed Float
accuracy Float
altitude Float
altitudeAccuracy Float
timestamp DateTime @db.Timestamptz(3)
}
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-08 12:41:37 +00:00
player Player @relation(fields: [playerId], references: [id])
playerId Int
challenge Challenge @relation(fields: [challengeId], references: [id])
challengeId Int @unique
active Boolean @default(false)
success Boolean @default(false)
start DateTime @default(now()) @db.Timestamptz(3)
end DateTime? @db.Timestamptz(3)
penaltyStart DateTime? @db.Timestamptz(3)
penaltyEnd DateTime? @db.Timestamptz(3)
moneyUpdate MoneyUpdate?
}
model TrainTrip {
id String @id
2024-12-08 12:41:37 +00:00
player Player @relation(fields: [playerId], references: [id])
playerId Int
distance Float
from String
to String
departureTime DateTime @db.Timestamptz(3)
arrivalTime DateTime @db.Timestamptz(3)
infoJson Json
moneyUpdate MoneyUpdate?
}
model MoneyUpdate {
id Int @id @default(autoincrement())
2024-12-08 12:41:37 +00:00
player Player @relation(fields: [playerId], references: [id])
playerId Int
amount Int
reason MoneyUpdateType
action ChallengeAction? @relation(fields: [actionId], references: [id])
actionId Int? @unique
trip TrainTrip? @relation(fields: [tripId], references: [id])
tripId String? @unique
timestamp DateTime @default(now()) @db.Timestamptz(3)
}
enum MoneyUpdateType {
START
WIN_CHALLENGE
BUY_TRAIN
}