1
Fork 0
mirror of https://github.com/Steffo99/festa.git synced 2024-10-16 15:07:27 +00:00
festa/prisma/schema.prisma

139 lines
3.5 KiB
Text
Raw Normal View History

2022-05-20 12:20:45 +00:00
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
2022-05-20 22:46:39 +00:00
provider = "prisma-client-js"
2022-05-20 12:11:08 +00:00
}
2022-05-20 12:20:45 +00:00
datasource db {
2022-05-20 22:46:39 +00:00
provider = "postgresql"
url = env("DATABASE_URL")
2022-05-20 12:20:45 +00:00
}
2022-05-20 17:15:47 +00:00
/// An event is the representation of a gathering of people in a certain place at a certain time.
model Event {
2022-05-20 22:46:39 +00:00
id Int @id @default(autoincrement())
//
slug String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
viewPassword String?
joinPassword String?
//
name String
description String
postcard String?
startTime DateTime?
endTime DateTime?
location String?
//
partecipants Partecipant[]
neededItems Item[]
vehicles Vehicle[]
2022-05-20 17:15:47 +00:00
}
/// A user is a person who is using the Festa website, who logged in via Telegram.
model User {
id BigInt @id
firstName String
lastName String?
username String?
photoUrl String?
lastAuthDate DateTime
hash String
}
2022-05-20 17:15:47 +00:00
/// A partecipant is a person who may or may not partecipate to the event.
model Partecipant {
2022-05-20 22:46:39 +00:00
id Int @id @default(autoincrement())
eventId Int
event Event @relation(fields: [eventId], references: [id])
//
name String
email String
//
means PartecipationMeans
createdAt DateTime @default(now())
joinedAt DateTime?
//
answer PartecipationAnswer
shouldBring Item[]
drives Vehicle[] @relation("VehicleDrive")
rides Vehicle[] @relation("VehicleRide")
expenses Transaction[] @relation("TransactionFrom")
income Transaction[] @relation("TransactionTo")
2022-05-20 17:15:47 +00:00
}
enum PartecipationMeans {
2022-05-20 22:46:39 +00:00
CREATOR
INVITED
ACCEPTED
JOINED
2022-05-20 17:15:47 +00:00
}
enum PartecipationAnswer {
2022-05-20 22:46:39 +00:00
HOST
YES
MAYBE
NO
PENDING
2022-05-20 17:15:47 +00:00
}
2022-05-20 17:43:47 +00:00
/// An item which should be bought and brought by somebody to the event.
2022-05-20 18:15:07 +00:00
model Item {
2022-05-20 22:46:39 +00:00
id Int @id @default(autoincrement())
eventId Int
event Event @relation(fields: [eventId], references: [id])
//
quantity Int
name String
purchased Boolean @default(false)
//
assignedId Int?
assigned Partecipant? @relation(fields: [assignedId], references: [id])
2022-05-20 17:43:47 +00:00
}
2022-05-20 18:15:07 +00:00
/// A vehicle which is being used to transport people from and to the event.
model Vehicle {
2022-05-20 22:46:39 +00:00
id Int @id @default(autoincrement())
eventId Int
event Event @relation(fields: [eventId], references: [id])
//
driverId Int
driver Partecipant @relation("VehicleDrive", fields: [driverId], references: [id])
riders Partecipant[] @relation("VehicleRide")
//
type VehicleType @default(CAR)
slots Int @default(4)
password String?
//
voyage VoyageType
location String
departureAt DateTime
arrivalAt DateTime
2022-05-20 18:17:25 +00:00
}
enum VehicleType {
2022-05-20 22:46:39 +00:00
CAR
OTHER
2022-05-20 18:15:07 +00:00
}
enum VoyageType {
2022-05-20 22:46:39 +00:00
TO
FROM
2022-05-20 18:15:07 +00:00
}
2022-05-20 21:28:14 +00:00
/// A monetary transaction related to the event.
model Transaction {
2022-05-20 22:46:39 +00:00
id Int @id @default(autoincrement())
//
fromId Int?
from Partecipant? @relation("TransactionFrom", fields: [fromId], references: [id])
toId Int?
to Partecipant? @relation("TransactionTo", fields: [toId], references: [id])
//
amount Decimal
currency String
reason String
2022-05-20 21:28:14 +00:00
}