Initial commit
This commit is contained in:
202
prisma/schema.prisma
Normal file
202
prisma/schema.prisma
Normal file
@@ -0,0 +1,202 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
enum Role {
|
||||
ADMIN
|
||||
USER
|
||||
}
|
||||
|
||||
enum RegistrationStatus {
|
||||
CONFIRMED
|
||||
PAYMENT_PENDING
|
||||
PAID
|
||||
CANCELLED
|
||||
}
|
||||
|
||||
enum WebinarVisibility {
|
||||
PUBLIC
|
||||
PRIVATE
|
||||
}
|
||||
|
||||
// BetterAuth User model
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
email String @unique
|
||||
emailVerified Boolean @default(false)
|
||||
image String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
// Custom fields
|
||||
role Role @default(USER)
|
||||
firstName String?
|
||||
lastName String?
|
||||
gender String?
|
||||
dob DateTime?
|
||||
address String?
|
||||
forcePasswordReset Boolean @default(false)
|
||||
isActive Boolean @default(true)
|
||||
|
||||
// BetterAuth relations
|
||||
accounts Account[]
|
||||
credential Credential?
|
||||
sessions Session[]
|
||||
verifications Verification[]
|
||||
|
||||
// Custom relations
|
||||
registrations WebinarRegistration[]
|
||||
contactMessages ContactMessage[] @relation("messageAuthor")
|
||||
}
|
||||
|
||||
// BetterAuth Account model (OAuth and email/password accounts)
|
||||
// Note: For email/password, credentials are stored differently by BetterAuth
|
||||
model Account {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
type String @default("oauth")
|
||||
provider String
|
||||
providerAccountId String
|
||||
refreshToken String?
|
||||
accessToken String?
|
||||
expiresAt Int?
|
||||
tokenType String?
|
||||
scope String?
|
||||
idToken String?
|
||||
sessionState String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([provider, providerAccountId])
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
// Credential table for email/password authentication
|
||||
model Credential {
|
||||
id String @id @default(cuid())
|
||||
userId String @unique
|
||||
password String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
// BetterAuth Session model
|
||||
model Session {
|
||||
id String @id @default(cuid())
|
||||
sessionToken String @unique
|
||||
userId String
|
||||
expires DateTime
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
// BetterAuth Verification model
|
||||
model Verification {
|
||||
id String @id @default(cuid())
|
||||
identifier String
|
||||
value String
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
userId String?
|
||||
|
||||
@@unique([identifier, value])
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
model SystemConfig {
|
||||
id Int @id
|
||||
data Json @default("{}")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model AppSetup {
|
||||
id Int @id
|
||||
googleAuthEnabled Boolean @default(false)
|
||||
googleClientId String?
|
||||
googleClientSecret String?
|
||||
socials Json @default("{}")
|
||||
categories Json @default("[]")
|
||||
paginationItemsPerPage Int @default(10)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model Webinar {
|
||||
id String @id @default(uuid())
|
||||
title String
|
||||
description String
|
||||
speaker String
|
||||
startAt DateTime
|
||||
duration Int
|
||||
bannerUrl String?
|
||||
category String
|
||||
visibility WebinarVisibility @default(PUBLIC)
|
||||
isActive Boolean @default(true)
|
||||
capacity Int
|
||||
priceCents Int @default(0)
|
||||
meetingInfo Json @default("{}")
|
||||
learningPoints Json @default("[]")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
registrations WebinarRegistration[]
|
||||
|
||||
@@index([visibility])
|
||||
@@index([isActive])
|
||||
}
|
||||
|
||||
model WebinarRegistration {
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
webinarId String
|
||||
status RegistrationStatus @default(CONFIRMED)
|
||||
stripeCheckoutSessionId String?
|
||||
stripePaymentIntentId String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
webinar Webinar @relation(fields: [webinarId], references: [id])
|
||||
|
||||
@@unique([userId, webinarId])
|
||||
@@index([userId])
|
||||
@@index([webinarId])
|
||||
}
|
||||
|
||||
model ContactMessage {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
email String
|
||||
subject String
|
||||
message String
|
||||
status String @default("NEW") // NEW, READ, REPLIED
|
||||
adminNote String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
authorId String?
|
||||
|
||||
author User? @relation("messageAuthor", fields: [authorId], references: [id])
|
||||
|
||||
@@index([status])
|
||||
@@index([createdAt])
|
||||
}
|
||||
Reference in New Issue
Block a user