230 lines
8.8 KiB
Plaintext
230 lines
8.8 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
output = "./generated"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("POSTGRES_URI")
|
|
}
|
|
|
|
model Stream {
|
|
id String @id @default(uuid())
|
|
title String
|
|
thumbnailUrl String? @map("thumbnail_url")
|
|
ingressId String? @unique @map("ingress_id")
|
|
serverUrl String? @map("server_url")
|
|
key String? @map("key")
|
|
isLive Boolean @default(false) @map("is_live")
|
|
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String? @unique @map("user_id")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
category Category? @relation(fields: [categoryId], references: [id], onDelete: Cascade)
|
|
categoryId String? @map("category_id")
|
|
chatMessages ChatMessage[]
|
|
isChatEnable Boolean @default(true) @map("is_chat_enable")
|
|
isChatFollowersOnly Boolean @default(false) @map("is_chat_followers_onlys")
|
|
isChatPremiumFollowersOnly Boolean @default(false) @map("is_chat_premium_followers_onlys")
|
|
|
|
@@map("stream")
|
|
}
|
|
|
|
model ChatMessage {
|
|
id String @id @default(uuid())
|
|
text String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String @map("user_id")
|
|
stream Stream @relation(fields: [streamId], references: [id], onDelete: Cascade)
|
|
streamId String @map("stream_id")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@map("chat_messages")
|
|
}
|
|
|
|
model Follow {
|
|
id String @id @default(uuid())
|
|
follower User @relation(name: "followers", fields: [followerId], references: [id], onDelete: Cascade)
|
|
followerId String @map("follower_id")
|
|
following User @relation(name: "followings", fields: [followingId], references: [id], onDelete: Cascade)
|
|
followingId String @map("following_id")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@unique([followingId, followerId])
|
|
@@index([followerId])
|
|
@@index([followingId])
|
|
@@map("follows")
|
|
}
|
|
|
|
model SocialLink {
|
|
id String @id @default(uuid())
|
|
title String
|
|
url String
|
|
position Int
|
|
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String? @map("user_id")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@map("social_links")
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid())
|
|
email String @unique
|
|
password String
|
|
name String @unique
|
|
displayName String @map("display_name")
|
|
avatar String?
|
|
bio String?
|
|
token Token[]
|
|
isVerified Boolean @default(false) @map("is_verified")
|
|
isEmailVerified Boolean @default(false) @map("is_email_verified")
|
|
isTotpEnabled Boolean @default(false) @map("is_totp_enabled")
|
|
isDeactivated Boolean @default(false) @map("is_deactivated")
|
|
deactivatedAt DateTime? @map("deactivated_at")
|
|
socialLink SocialLink[]
|
|
totpSecret String? @map("totp_secret")
|
|
stream Stream?
|
|
chatMessages ChatMessage[]
|
|
followers Follow[] @relation(name: "followers")
|
|
followings Follow[] @relation(name: "followings")
|
|
notifications Notification[]
|
|
notificationSettings NotificationSettings?
|
|
telegramId String? @unique @map("telegram_id")
|
|
transactions Transaction[]
|
|
sponsorshipPlans SponsorshipPlan[]
|
|
sponsorshipSubscriptions SponsorshipSubscription[] @relation(name: "sponsorship_subscriptions")
|
|
sponsors SponsorshipSubscription[] @relation(name: "sponsors")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@map("users")
|
|
}
|
|
|
|
model Category {
|
|
id String @id @default(uuid())
|
|
title String
|
|
slug String @unique
|
|
description String?
|
|
thumbnailUrl String @map("thumbnail_url")
|
|
streams Stream[]
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@map("categories")
|
|
}
|
|
|
|
model Token {
|
|
id String @id @default(uuid())
|
|
token String @unique
|
|
type TokenType
|
|
expiresIn DateTime @map("expires_in")
|
|
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String? @map("user_id")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@map("tokens")
|
|
}
|
|
|
|
model Transaction {
|
|
id String @id @default(uuid())
|
|
amount Float
|
|
currency String
|
|
stripeSubscriptionId String? @map("stripe_subscription_id")
|
|
status TransactionStatus @default(PENDING)
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String @map("user_id")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@map("transactions")
|
|
}
|
|
|
|
model SponsorshipPlan {
|
|
id String @id @default(uuid())
|
|
title String
|
|
description String?
|
|
price Float
|
|
stripeProductId String @map("stripe_product_id")
|
|
stripePlanId String @map("stripe_plan_id")
|
|
channel User? @relation(fields: [channelId], references: [id], onDelete: Cascade)
|
|
channelId String? @map("channel_id")
|
|
sponsorshipSubscriptions SponsorshipSubscription[]
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@map("sponsorship_plans")
|
|
}
|
|
|
|
model SponsorshipSubscription {
|
|
id String @id @default(uuid())
|
|
expiresAt DateTime @map("expires_at")
|
|
plan SponsorshipPlan? @relation(fields: [planId], references: [id], onDelete: Cascade)
|
|
planId String? @map("plan_id")
|
|
user User? @relation(name: "sponsorship_subscriptions", fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String? @map("user_id")
|
|
channel User? @relation(name: "sponsors", fields: [channelId], references: [id], onDelete: Cascade)
|
|
channelId String? @map("channel_id")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@map("sponsorship_subscriptions")
|
|
}
|
|
|
|
model Notification {
|
|
id String @id @default(uuid())
|
|
text String
|
|
type NotificationType
|
|
isRead Boolean @default(false) @map("is_read")
|
|
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String? @map("user_id")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@map("notifications")
|
|
}
|
|
|
|
model NotificationSettings {
|
|
id String @id @default(uuid())
|
|
siteNotifications Boolean @default(true) @map("site_notifications")
|
|
telegramNotifications Boolean @default(true) @map("telegram_notifications")
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String @unique @map("user_id")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@map("notification_settings")
|
|
}
|
|
|
|
enum NotificationType {
|
|
STREAM_START
|
|
NEW_FOLLOWER
|
|
NEW_SPONSORSHIP
|
|
ENABLE_TWO_FACTOR
|
|
VERIFIED_CHANNEL
|
|
|
|
@@map("notification_types")
|
|
}
|
|
|
|
enum TokenType {
|
|
EMAIL_VERIFY
|
|
PASSWORD_RESET
|
|
DEACTIVATE_ACCOUNT
|
|
TELEGRAM_AUTH
|
|
|
|
@@map("token_types")
|
|
}
|
|
|
|
enum TransactionStatus {
|
|
PENDING
|
|
SUCCESS
|
|
FAILED
|
|
EXPIRED
|
|
|
|
@@map("transaction_statuses")
|
|
}
|