Block 8 complete: streaks, notifications, referrals, premium identity, gamification
This commit is contained in:
@@ -38,6 +38,58 @@ model User {
|
||||
forumThreads ForumThread[]
|
||||
forumPosts ForumPost[]
|
||||
chatHistory ChatHistory[]
|
||||
notifications Notification[]
|
||||
referredReferrals Referral[] @relation("Referrer")
|
||||
referrerReferral Referral? @relation("Referred")
|
||||
dailyStreak DailyStreak?
|
||||
xpTransactions XpTransaction[]
|
||||
achievements Achievement[]
|
||||
userLevel UserLevel?
|
||||
}
|
||||
|
||||
model DailyStreak {
|
||||
userId String @id
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
currentStreak Int @default(0)
|
||||
longestStreak Int @default(0)
|
||||
lastClaimDate DateTime?
|
||||
streakFreeze Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model XpTransaction {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
amount Int
|
||||
reason String // 'daily_login' | 'chat_message' | 'forum_post' | 'purchase' | 'referral' | 'achievement'
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
model Achievement {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
type String // 'first_chat' | 'streak_7' | 'streak_30' | 'level_5' | 'first_purchase' | 'first_post'
|
||||
title String
|
||||
description String?
|
||||
icon String?
|
||||
unlockedAt DateTime @default(now())
|
||||
|
||||
@@index([userId])
|
||||
@@unique([userId, type])
|
||||
}
|
||||
|
||||
model UserLevel {
|
||||
userId String @id
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
level Int @default(1)
|
||||
xp Int @default(0)
|
||||
xpToNext Int @default(100)
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model Listing {
|
||||
@@ -153,9 +205,51 @@ model HalalUsage {
|
||||
periodEnd DateTime?
|
||||
}
|
||||
|
||||
model Notification {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
type String // 'streak_reminder' | 'daily_verse' | 'premium_expiring' | 'new_listing' | 'forum_reply' | 'achievement' | 'referral_bonus'
|
||||
title String
|
||||
body String?
|
||||
data String? // JSON string with extra payload
|
||||
read Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@index([userId, read])
|
||||
}
|
||||
|
||||
model Referral {
|
||||
id String @id @default(cuid())
|
||||
referrerId String
|
||||
referrer User @relation("Referrer", fields: [referrerId], references: [id])
|
||||
referredId String @unique
|
||||
referred User @relation("Referred", fields: [referredId], references: [id])
|
||||
status String @default("pending") // pending | joined | upgraded
|
||||
rewardFlh Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
upgradedAt DateTime?
|
||||
|
||||
@@index([referrerId])
|
||||
}
|
||||
|
||||
model PremiumBenefit {
|
||||
id String @id @default(cuid())
|
||||
tier String // 'premium' | 'pro'
|
||||
name String
|
||||
description String?
|
||||
icon String?
|
||||
active Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
}
|
||||
|
||||
model HalalPlaceCache {
|
||||
id String @id @default(cuid())
|
||||
cacheKey String @unique
|
||||
data String
|
||||
expiresAt DateTime
|
||||
}
|
||||
|
||||
// Add Relations to User model
|
||||
/// NOTE: The Notification and Referral relations are declared on the models above.
|
||||
/// User now implicitly has: notifications Notification[], referredReferrals Referral[] (via "Referrer"), referrerReferral Referral? (via "Referred")
|
||||
|
||||
Reference in New Issue
Block a user