156 lines
3.8 KiB
Plaintext
156 lines
3.8 KiB
Plaintext
// Prisma Schema for DevFlix / InfoFlix Subscription Platform
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
enum Role {
|
|
admin
|
|
student
|
|
}
|
|
|
|
enum SubscriptionStatus {
|
|
ACTIVE
|
|
OVERDUE
|
|
CANCELED
|
|
TRIAL
|
|
}
|
|
|
|
enum VideoType {
|
|
youtube
|
|
direct
|
|
}
|
|
|
|
enum PaymentStatus {
|
|
PENDING
|
|
RECEIVED
|
|
CONFIRMED
|
|
OVERDUE
|
|
REFUNDED
|
|
}
|
|
|
|
enum BillingType {
|
|
PIX
|
|
CREDIT_CARD
|
|
BOLETO
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid())
|
|
name String
|
|
email String @unique
|
|
password String
|
|
role Role @default(student)
|
|
subscriptionStatus SubscriptionStatus @default(TRIAL) @map("subscription_status")
|
|
asaasCustomerId String? @map("asaas_customer_id")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
notes Note[]
|
|
progress Progress[]
|
|
payments Payment[]
|
|
|
|
@@map("users")
|
|
}
|
|
|
|
model Course {
|
|
id String @id @default(uuid())
|
|
title String
|
|
description String @db.Text
|
|
thumbnail String
|
|
category String
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
modules Module[]
|
|
|
|
@@map("courses")
|
|
}
|
|
|
|
model Module {
|
|
id String @id @default(uuid())
|
|
courseId String @map("course_id")
|
|
title String
|
|
order Int
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
|
|
lessons Lesson[]
|
|
|
|
@@map("modules")
|
|
}
|
|
|
|
model Lesson {
|
|
id String @id @default(uuid())
|
|
moduleId String @map("module_id")
|
|
title String
|
|
videoUrl String @map("video_url") @db.Text
|
|
videoType VideoType @map("video_type")
|
|
order Int
|
|
content String? @db.Text
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
module Module @relation(fields: [moduleId], references: [id], onDelete: Cascade)
|
|
notes Note[]
|
|
progress Progress[]
|
|
|
|
@@map("lessons")
|
|
}
|
|
|
|
model Note {
|
|
id String @id @default(uuid())
|
|
userId String @map("user_id")
|
|
lessonId String @map("lesson_id")
|
|
content String @db.Text
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
lesson Lesson @relation(fields: [lessonId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([userId, lessonId])
|
|
@@map("notes")
|
|
}
|
|
|
|
model Progress {
|
|
id String @id @default(uuid())
|
|
userId String @map("user_id")
|
|
lessonId String @map("lesson_id")
|
|
watchedPercentage Int @default(0) @map("watched_percentage")
|
|
completed Boolean @default(false)
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
lesson Lesson @relation(fields: [lessonId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([userId, lessonId])
|
|
@@map("progress")
|
|
}
|
|
|
|
model Payment {
|
|
id String @id
|
|
userId String @map("user_id")
|
|
value Decimal @db.Decimal(10, 2)
|
|
status PaymentStatus
|
|
billingType BillingType @map("billing_type")
|
|
invoiceUrl String @map("invoice_url") @db.Text
|
|
dueDate DateTime @map("due_date") @db.Date
|
|
paidAt DateTime? @map("paid_at")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@map("payments")
|
|
}
|
|
|
|
model WebhookLog {
|
|
id String @id @default(uuid())
|
|
event String
|
|
payload String @db.Text
|
|
receivedAt DateTime @default(now()) @map("received_at")
|
|
|
|
@@map("webhook_logs")
|
|
}
|