// This is your Prisma schema file // Learn more: https://pris.ly/d/prisma-schema generator client { provider = "prisma-client-js" } datasource db { provider = "postgresql" url = env("DATABASE_URL") } model Message { id String @id @default(uuid()) content String @db.VarChar(267) authorIp String createdAt DateTime @default(now()) parentId String? // Rich-message tiers (paid): "none" | "htmlcss" | "js". richContent holds the raw // markup/script, rendered ONLY inside a sandboxed iframe on the client. richMode String @default("none") richContent String? @db.Text parent Message? @relation("ThreadReplies", fields: [parentId], references: [id]) replies Message[] @relation("ThreadReplies") attachments Attachment[] @@map("messages") } // ── Economy: fictional "crédits XIP", keyed on IP (no accounts) ────────────── model Wallet { ip String @id balance Int @default(0) // centi-credits (9.99 "€" => 999) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@map("wallets") } // Seeded catalogue of purchasable features (faithful to the shop mockups). model Product { id String @id // slug: "cadre-pub","noads","style-dore","pet","bundle-cosmetic","rich-htmlcss","rich-js","no-file-limit","audio-alert" category String // "publicite" | "abonnements" | "cosmetiques" | "promotions" | "premium" name String subtitle String? kind String // "ad-frame" | "subscription" | "ip-skin" | "pet" | "bundle" | "rich" | "unlock" | "consumable" basePrice Int // centi-credits promoPrice Int? badge String? stockLimit Int? // e.g. 50 for style-dore; null = unlimited stockSold Int @default(0) active Boolean @default(true) sortOrder Int @default(0) metaJson String? @db.Text // options config (durations, formats, pet designs, plans…) @@map("products") } // Append-only ledger: every credit movement (top-up, purchase, grant). model Purchase { id String @id @default(uuid()) ip String productId String? type String // "topup" | "purchase" | "grant" amount Int // signed centi-credits: negative = spend, positive = grant metaJson String? @db.Text createdAt DateTime @default(now()) @@index([ip]) @@map("purchases") } // What an IP owns. Drives perks (skin/pets/noads), rich unlocks, ad frames, etc. model Entitlement { id String @id @default(uuid()) ip String kind String // "noads" | "style-dore" | "pet" | "rich-htmlcss" | "rich-js" | "no-file-limit" | "ad-frame" | "audio-alert" | "element-skin" active Boolean @default(true) expiresAt DateTime? // subscriptions / ad-frame duration; null = permanent metaJson String? @db.Text // pet: {design,position}; ad-frame: {format,url,days}; etc. createdAt DateTime @default(now()) @@index([ip]) @@index([ip, kind]) @@map("entitlements") } // ── Real ad inventory (replaces the hardcoded AdBand / InlineCasinoAd) ─────── model Ad { id String @id @default(uuid()) brand String subtitle String? url String? cta String? icon String? tone String // "blue" | "green" | "purple" | "casino" | "user" kind String // "band" | "casino" weight Int @default(1) active Boolean @default(true) ownerIp String? // set when bought via "Cadre de Pub" format String? // "static" | "gif" imageUrl String? expiresAt DateTime? impressions Int @default(0) createdAt DateTime @default(now()) @@index([kind, active]) @@map("ads") } // ── File attachments (free <=1 Mo; paid "no-file-limit" lifts the cap) ─────── model Attachment { id String @id @default(uuid()) messageId String? ip String filename String mimeType String size Int storagePath String createdAt DateTime @default(now()) message Message? @relation(fields: [messageId], references: [id], onDelete: Cascade) @@index([messageId]) @@map("attachments") }