299 lines
8.5 KiB
Plaintext
299 lines
8.5 KiB
Plaintext
|
|
// Prisma Schema para HotWives Platform
|
||
|
|
|
||
|
|
generator client {
|
||
|
|
provider = "prisma-client-js"
|
||
|
|
}
|
||
|
|
|
||
|
|
datasource db {
|
||
|
|
provider = "postgresql"
|
||
|
|
url = env("DATABASE_URL")
|
||
|
|
}
|
||
|
|
|
||
|
|
enum UserRole {
|
||
|
|
USER
|
||
|
|
PREMIUM
|
||
|
|
ADMIN
|
||
|
|
MODERATOR
|
||
|
|
}
|
||
|
|
|
||
|
|
enum Gender {
|
||
|
|
MALE
|
||
|
|
FEMALE
|
||
|
|
COUPLE
|
||
|
|
OTHER
|
||
|
|
}
|
||
|
|
|
||
|
|
enum RelationshipType {
|
||
|
|
SINGLE
|
||
|
|
COUPLE
|
||
|
|
OPEN_RELATIONSHIP
|
||
|
|
COMPLICATED
|
||
|
|
}
|
||
|
|
|
||
|
|
enum VerificationStatus {
|
||
|
|
UNVERIFIED
|
||
|
|
PENDING
|
||
|
|
VERIFIED
|
||
|
|
REJECTED
|
||
|
|
}
|
||
|
|
|
||
|
|
enum EventStatus {
|
||
|
|
DRAFT
|
||
|
|
PUBLISHED
|
||
|
|
CANCELLED
|
||
|
|
COMPLETED
|
||
|
|
}
|
||
|
|
|
||
|
|
model User {
|
||
|
|
id String @id @default(uuid())
|
||
|
|
email String @unique
|
||
|
|
password String
|
||
|
|
role UserRole @default(USER)
|
||
|
|
isActive Boolean @default(true)
|
||
|
|
emailVerified Boolean @default(false)
|
||
|
|
verificationToken String?
|
||
|
|
resetToken String?
|
||
|
|
resetTokenExpiry DateTime?
|
||
|
|
lastLogin DateTime?
|
||
|
|
createdAt DateTime @default(now())
|
||
|
|
updatedAt DateTime @updatedAt
|
||
|
|
|
||
|
|
// Relacionamentos
|
||
|
|
profile Profile?
|
||
|
|
sentMessages Message[] @relation("SentMessages")
|
||
|
|
receivedMessages Message[] @relation("ReceivedMessages")
|
||
|
|
favoriteUsers Favorite[] @relation("UserFavorites")
|
||
|
|
favoritedBy Favorite[] @relation("FavoritedUser")
|
||
|
|
blockedUsers Block[] @relation("UserBlocks")
|
||
|
|
blockedBy Block[] @relation("BlockedUser")
|
||
|
|
photos Photo[]
|
||
|
|
events Event[]
|
||
|
|
eventParticipants EventParticipant[]
|
||
|
|
reports Report[] @relation("ReportCreator")
|
||
|
|
reportedIn Report[] @relation("ReportedUser")
|
||
|
|
notifications Notification[]
|
||
|
|
subscriptions Subscription[]
|
||
|
|
|
||
|
|
@@index([email])
|
||
|
|
@@index([role])
|
||
|
|
}
|
||
|
|
|
||
|
|
model Profile {
|
||
|
|
id String @id @default(uuid())
|
||
|
|
userId String @unique
|
||
|
|
username String @unique
|
||
|
|
displayName String
|
||
|
|
bio String? @db.Text
|
||
|
|
age Int?
|
||
|
|
gender Gender
|
||
|
|
relationshipType RelationshipType
|
||
|
|
location String?
|
||
|
|
city String?
|
||
|
|
state String?
|
||
|
|
country String @default("Brasil")
|
||
|
|
avatarUrl String?
|
||
|
|
coverUrl String?
|
||
|
|
verificationStatus VerificationStatus @default(UNVERIFIED)
|
||
|
|
verificationPhotoUrl String?
|
||
|
|
|
||
|
|
// Preferências
|
||
|
|
lookingFor String[]
|
||
|
|
interests String[]
|
||
|
|
languages String[]
|
||
|
|
|
||
|
|
// Privacidade
|
||
|
|
showAge Boolean @default(true)
|
||
|
|
showLocation Boolean @default(true)
|
||
|
|
showOnline Boolean @default(true)
|
||
|
|
allowMessages Boolean @default(true)
|
||
|
|
|
||
|
|
// Estatísticas
|
||
|
|
profileViews Int @default(0)
|
||
|
|
photoCount Int @default(0)
|
||
|
|
favoritesCount Int @default(0)
|
||
|
|
|
||
|
|
createdAt DateTime @default(now())
|
||
|
|
updatedAt DateTime @updatedAt
|
||
|
|
|
||
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||
|
|
|
||
|
|
@@index([username])
|
||
|
|
@@index([gender])
|
||
|
|
@@index([city])
|
||
|
|
@@index([verificationStatus])
|
||
|
|
}
|
||
|
|
|
||
|
|
model Photo {
|
||
|
|
id String @id @default(uuid())
|
||
|
|
userId String
|
||
|
|
url String
|
||
|
|
thumbnail String?
|
||
|
|
isPrivate Boolean @default(false)
|
||
|
|
isAvatar Boolean @default(false)
|
||
|
|
isCover Boolean @default(false)
|
||
|
|
caption String?
|
||
|
|
order Int @default(0)
|
||
|
|
likes Int @default(0)
|
||
|
|
views Int @default(0)
|
||
|
|
createdAt DateTime @default(now())
|
||
|
|
updatedAt DateTime @updatedAt
|
||
|
|
|
||
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||
|
|
|
||
|
|
@@index([userId])
|
||
|
|
@@index([isPrivate])
|
||
|
|
}
|
||
|
|
|
||
|
|
model Message {
|
||
|
|
id String @id @default(uuid())
|
||
|
|
senderId String
|
||
|
|
receiverId String
|
||
|
|
content String @db.Text
|
||
|
|
isRead Boolean @default(false)
|
||
|
|
readAt DateTime?
|
||
|
|
createdAt DateTime @default(now())
|
||
|
|
|
||
|
|
sender User @relation("SentMessages", fields: [senderId], references: [id], onDelete: Cascade)
|
||
|
|
receiver User @relation("ReceivedMessages", fields: [receiverId], references: [id], onDelete: Cascade)
|
||
|
|
|
||
|
|
@@index([senderId])
|
||
|
|
@@index([receiverId])
|
||
|
|
@@index([createdAt])
|
||
|
|
}
|
||
|
|
|
||
|
|
model Favorite {
|
||
|
|
id String @id @default(uuid())
|
||
|
|
userId String
|
||
|
|
favoriteId String
|
||
|
|
createdAt DateTime @default(now())
|
||
|
|
|
||
|
|
user User @relation("UserFavorites", fields: [userId], references: [id], onDelete: Cascade)
|
||
|
|
favorite User @relation("FavoritedUser", fields: [favoriteId], references: [id], onDelete: Cascade)
|
||
|
|
|
||
|
|
@@unique([userId, favoriteId])
|
||
|
|
@@index([userId])
|
||
|
|
@@index([favoriteId])
|
||
|
|
}
|
||
|
|
|
||
|
|
model Block {
|
||
|
|
id String @id @default(uuid())
|
||
|
|
userId String
|
||
|
|
blockedId String
|
||
|
|
reason String?
|
||
|
|
createdAt DateTime @default(now())
|
||
|
|
|
||
|
|
user User @relation("UserBlocks", fields: [userId], references: [id], onDelete: Cascade)
|
||
|
|
blocked User @relation("BlockedUser", fields: [blockedId], references: [id], onDelete: Cascade)
|
||
|
|
|
||
|
|
@@unique([userId, blockedId])
|
||
|
|
@@index([userId])
|
||
|
|
@@index([blockedId])
|
||
|
|
}
|
||
|
|
|
||
|
|
model Event {
|
||
|
|
id String @id @default(uuid())
|
||
|
|
creatorId String
|
||
|
|
title String
|
||
|
|
description String @db.Text
|
||
|
|
date DateTime
|
||
|
|
endDate DateTime?
|
||
|
|
location String
|
||
|
|
city String
|
||
|
|
state String
|
||
|
|
country String @default("Brasil")
|
||
|
|
address String?
|
||
|
|
coverImage String?
|
||
|
|
maxParticipants Int?
|
||
|
|
isPrivate Boolean @default(false)
|
||
|
|
requiresApproval Boolean @default(true)
|
||
|
|
status EventStatus @default(DRAFT)
|
||
|
|
tags String[]
|
||
|
|
price Float?
|
||
|
|
createdAt DateTime @default(now())
|
||
|
|
updatedAt DateTime @updatedAt
|
||
|
|
|
||
|
|
creator User @relation(fields: [creatorId], references: [id], onDelete: Cascade)
|
||
|
|
participants EventParticipant[]
|
||
|
|
|
||
|
|
@@index([creatorId])
|
||
|
|
@@index([date])
|
||
|
|
@@index([city])
|
||
|
|
@@index([status])
|
||
|
|
}
|
||
|
|
|
||
|
|
model EventParticipant {
|
||
|
|
id String @id @default(uuid())
|
||
|
|
eventId String
|
||
|
|
userId String
|
||
|
|
status String @default("pending") // pending, approved, rejected
|
||
|
|
message String?
|
||
|
|
createdAt DateTime @default(now())
|
||
|
|
updatedAt DateTime @updatedAt
|
||
|
|
|
||
|
|
event Event @relation(fields: [eventId], references: [id], onDelete: Cascade)
|
||
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||
|
|
|
||
|
|
@@unique([eventId, userId])
|
||
|
|
@@index([eventId])
|
||
|
|
@@index([userId])
|
||
|
|
}
|
||
|
|
|
||
|
|
model Report {
|
||
|
|
id String @id @default(uuid())
|
||
|
|
reporterId String
|
||
|
|
reportedId String
|
||
|
|
reason String
|
||
|
|
description String? @db.Text
|
||
|
|
status String @default("pending") // pending, reviewing, resolved, dismissed
|
||
|
|
resolution String? @db.Text
|
||
|
|
createdAt DateTime @default(now())
|
||
|
|
updatedAt DateTime @updatedAt
|
||
|
|
|
||
|
|
reporter User @relation("ReportCreator", fields: [reporterId], references: [id], onDelete: Cascade)
|
||
|
|
reported User @relation("ReportedUser", fields: [reportedId], references: [id], onDelete: Cascade)
|
||
|
|
|
||
|
|
@@index([reporterId])
|
||
|
|
@@index([reportedId])
|
||
|
|
@@index([status])
|
||
|
|
}
|
||
|
|
|
||
|
|
model Notification {
|
||
|
|
id String @id @default(uuid())
|
||
|
|
userId String
|
||
|
|
type String // message, like, favorite, event, system
|
||
|
|
title String
|
||
|
|
message String @db.Text
|
||
|
|
link String?
|
||
|
|
isRead Boolean @default(false)
|
||
|
|
createdAt DateTime @default(now())
|
||
|
|
|
||
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||
|
|
|
||
|
|
@@index([userId])
|
||
|
|
@@index([isRead])
|
||
|
|
@@index([createdAt])
|
||
|
|
}
|
||
|
|
|
||
|
|
model Subscription {
|
||
|
|
id String @id @default(uuid())
|
||
|
|
userId String
|
||
|
|
plan String // premium_monthly, premium_yearly
|
||
|
|
status String @default("active") // active, cancelled, expired
|
||
|
|
startDate DateTime @default(now())
|
||
|
|
endDate DateTime
|
||
|
|
autoRenew Boolean @default(true)
|
||
|
|
paymentMethod String?
|
||
|
|
transactionId String?
|
||
|
|
amount Float
|
||
|
|
currency String @default("BRL")
|
||
|
|
createdAt DateTime @default(now())
|
||
|
|
updatedAt DateTime @updatedAt
|
||
|
|
|
||
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||
|
|
|
||
|
|
@@index([userId])
|
||
|
|
@@index([status])
|
||
|
|
@@index([endDate])
|
||
|
|
}
|
||
|
|
|