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

91 lines
3.5 KiB
Text
Raw Normal View History

2022-05-29 02:01:56 +00:00
// Prisma Schema file
// https://pris.ly/d/prisma-schema
2022-05-20 12:11:08 +00:00
2022-05-29 02:01:56 +00:00
// Use the PostgreSQL database at the URL specified via the DATABASE_URL environment variable.
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
2022-05-29 02:01:56 +00:00
// Generate @prisma/client for use in JavaScript and TypeScript.
generator client {
provider = "prisma-client-js"
2022-05-20 17:15:47 +00:00
}
2022-05-29 02:01:56 +00:00
/// A person who is using the Festa website, who may have logged in via various account types.
model User {
2022-05-29 02:01:56 +00:00
/// A unique id for the user on the Festa website.
id String @id @default(uuid()) @db.Uuid
/// The power level of the user on the Festa website.
powerLevel PowerLevel @default(USER)
/// The displayed name of the user.
displayName String
/// The URL of the displayed avatar of the user.
displayAvatarURL String?
/// The tokens the user can use to login.
tokens Token[]
/// The Telegram accounts associated with this user.
accountsTelegram AccountTelegram[]
2022-05-30 03:19:49 +00:00
/// The events created by this user.
eventsCreated Event[]
2022-05-20 17:43:47 +00:00
}
2022-05-20 18:15:07 +00:00
2022-05-29 02:01:56 +00:00
/// A possible powerLevel value for an {@link User}.
enum PowerLevel {
/// The user has no special privileges.
USER
/// The user can override any permission check.
SUPERUSER
2022-05-20 18:17:25 +00:00
}
2022-05-29 02:01:56 +00:00
/// A container for user data associated with a single [Telegram](https://telegram.org/).
model AccountTelegram {
/// The id of the {@link User} associated with this account.
2022-05-30 03:19:49 +00:00
userId String @db.Uuid
2022-05-29 02:01:56 +00:00
/// The {@link User} associated with this account.
2022-05-30 03:19:49 +00:00
user User @relation(fields: [userId], references: [id])
2022-05-29 02:01:56 +00:00
/// The Telegram id of the account.
telegramId Int @id
/// The Telegram first name of the account. Always present.
firstName String
/// The Telegram last name of the account. May be omitted.
lastName String?
/// The username of the account. May not be present if the account has not opted in to public discovery on Telegram.
/// If set, allows the user to be contacted via `https://t.me/USERNAME`.
username String?
/// The URL where the user's avatar is accessible at.
photoUrl String?
/// The locale of the user. Its presence is VERY inconsistent, don't make any assumption based on that.
lang String?
/// The last time the account was updated.
updatedAt DateTime @updatedAt
2022-05-20 18:15:07 +00:00
}
2022-05-30 03:19:49 +00:00
/// An entity that can be used to authenticate to the API as an {@link User}.
2022-05-29 02:01:56 +00:00
model Token {
/// The id of the user that the token allows to login as.
userId String @db.Uuid
/// The user that the token allows to login as.
user User @relation(fields: [userId], references: [id])
/// The token itself, a string.
token String @id
/// The datetime after which the token should cease to be valid for authentication.
expiresAt DateTime
2022-05-20 21:28:14 +00:00
}
2022-05-30 03:19:49 +00:00
/// The core of the project, a single instance of people gathering in a certain place at a certain time.
model Event {
/// An unique url-safe string identifying the event, and allowing it to be accessed at `/events/SLUG`.
2022-06-04 03:13:19 +00:00
slug String @id
2022-05-30 03:19:49 +00:00
/// The id of the {@link User} who created the event.
2022-06-04 03:13:19 +00:00
creatorId String @db.Uuid
2022-05-30 03:19:49 +00:00
/// The {@link User} who created the event.
2022-06-04 03:13:19 +00:00
creator User @relation(fields: [creatorId], references: [id])
2022-05-30 03:19:49 +00:00
/// The name of the event.
2022-06-04 03:13:19 +00:00
name String
2022-06-03 02:07:12 +00:00
/// The URL to the postcard of the event.
2022-06-04 03:13:19 +00:00
postcard String?
/// The description of the event. It will be parsed in Markdown!
description String @default("")
2022-05-30 03:19:49 +00:00
}