refactor: migrate to tsup for builds and update tsconfigs fix: update error handling and validation in payment service chore: update package scripts and dependencies docs: update README and env examples
133 lines
3.3 KiB
Plaintext
133 lines
3.3 KiB
Plaintext
// This is your Prisma schema file,
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
|
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
output = "../generated/prisma"
|
|
}
|
|
|
|
generator zod {
|
|
provider = "zod-prisma-types"
|
|
output = "../generated/zod"
|
|
writeBarrelFiles = false // default is true
|
|
createInputTypes = false // default is true
|
|
createModelTypes = true // default is true
|
|
addInputTypeValidation = false // default is true
|
|
addIncludeType = false // default is true
|
|
addSelectType = false // default is true
|
|
validateWhereUniqueInput = false // default is true
|
|
}
|
|
|
|
generator json {
|
|
provider = "prisma-json-types-generator"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model TelegramSession {
|
|
id String @id
|
|
data Json
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model TelegramUser {
|
|
id String @id
|
|
username String?
|
|
isBlocked Boolean @default(false)
|
|
firstName String?
|
|
lastName String?
|
|
languageCode String?
|
|
isPremium Boolean?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
payments Payment[]
|
|
subscription Subscription?
|
|
}
|
|
|
|
model Payment {
|
|
id String @id @default(cuid())
|
|
telegramUserId String
|
|
amount Decimal @db.Decimal(10, 2)
|
|
currency String
|
|
status PaymentStatus @default(PENDING)
|
|
provider String
|
|
providerId String?
|
|
metadata Json?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
telegramUser TelegramUser @relation(fields: [telegramUserId], references: [id])
|
|
}
|
|
|
|
enum PaymentStatus {
|
|
PENDING
|
|
COMPLETED
|
|
FAILED
|
|
REFUNDED
|
|
}
|
|
|
|
model Plan {
|
|
id String @id @default(uuid())
|
|
code String @unique()
|
|
name String
|
|
description String?
|
|
durationDays Int
|
|
dailyGenerations Int
|
|
price Int
|
|
currency String
|
|
|
|
subscriptions Subscription[]
|
|
|
|
@@index([code])
|
|
}
|
|
|
|
model Subscription {
|
|
id String @id @default(uuid())
|
|
telegramUserId String @unique
|
|
planId String
|
|
|
|
startedAt DateTime @default(now())
|
|
expiresAt DateTime
|
|
canceledAt DateTime?
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
plan Plan @relation(fields: [planId], references: [id], onDelete: Cascade)
|
|
telegramUser TelegramUser @relation(fields: [telegramUserId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([telegramUserId])
|
|
@@index([planId])
|
|
}
|
|
|
|
model File {
|
|
id String @id @default(uuid())
|
|
filename String
|
|
originalName String
|
|
mimeType String
|
|
size Int
|
|
path String
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
links FileLink[]
|
|
}
|
|
|
|
model FileLink {
|
|
id String @id @default(uuid())
|
|
fileId String
|
|
relationId String
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
file File @relation(fields: [fileId], references: [id], onDelete: Cascade)
|
|
}
|