import { config } from 'dotenv'; config(); import { PrismaClient } from '@prisma/client'; import { PrismaPg } from '@prisma/adapter-pg'; import { Pool } from 'pg'; const connectionString = process.env.DATABASE_URL; const pool = new Pool({ connectionString }); const adapter = new PrismaPg(pool); const prisma = new PrismaClient({ adapter }); async function main() { console.log('Seeding plans...'); const plans = [ { id: 'free', name: 'free', displayName: 'Gratuit', price: 0, description: 'Idéal pour découvrir Pluume.', maxProjects: 1, maxAiActions: 10, features: ['10 actions IA / mois', '1 projet actif', 'Bible du monde simple'], isPopular: false, }, { id: 'pro', name: 'pro', displayName: 'Auteur Pro', price: 12, description: 'Pour les écrivains sérieux.', maxProjects: 5, // -1 means unlimited maxAiActions: 75, features: ['75 actions IA / mois', 'Projets illimités', 'Export Word & EPUB', 'Support prioritaire'], isPopular: true, }, { id: 'master', name: 'master', displayName: 'Maître Pluume', price: 29, description: 'Le summum de l\'écriture IA.', maxProjects: 20, maxAiActions: 250, // -1 means unlimited features: ['250 actions IA / mois', 'Accès Gemini 3 Pro', 'Bible du monde avancée', 'Outils de révision avancés'], isPopular: false, }, { id: 'byok', name: 'byok', displayName: 'Clé Perso (BYOK)', price: 4.99, description: 'Utilisez vos propres clés API (ChatGPT, Claude, Gemini).', maxProjects: -1, maxAiActions: -1, features: ['Tokens illimités via votre clé', 'Mode Bring Your Own Key', 'Choix du modèle IA', 'Projets illimités'], isPopular: false, }, ]; for (const plan of plans) { await prisma.plan.upsert({ where: { id: plan.id }, update: plan, create: plan, }); } console.log('Plans seeded successfully.'); } main() .catch((e) => { console.error(e); process.exit(1); }) .finally(async () => { await prisma.$disconnect(); });