import pkg from '@prisma/client'; const { PrismaClient } = pkg; import { PrismaPg } from '@prisma/adapter-pg'; import pg from 'pg'; import dotenv from 'dotenv'; dotenv.config({ path: '.env.local' }); dotenv.config(); const connectionString = process.env.DATABASE_URL!; const pool = new pg.Pool({ connectionString }); const adapter = new PrismaPg(pool); const prisma = new PrismaClient({ adapter }); const Plan = { STARTER: 'STARTER', BOOSTER: 'BOOSTER', EMPIRE: 'EMPIRE' } as const; async function main() { console.log('Seeding pricing plans...'); const plans = [ { tier: Plan.STARTER, name: 'Starter', priceXOF: 'Gratuit', yearlyPriceXOF: 'Gratuit', priceEUR: '0€', yearlyPriceEUR: '0€', description: 'Pour démarrer votre présence en ligne.', features: [ 'Fiche entreprise basique', 'Visible dans la recherche', '1 Offre produit/service', 'Support par email' ], offerLimit: 1, recommended: false, color: 'gray' }, { tier: Plan.BOOSTER, name: 'Booster', priceXOF: '3 500 FCFA', yearlyPriceXOF: '33 500 FCFA', priceEUR: '5€', yearlyPriceEUR: '48€', description: "L'indispensable pour les entreprises en croissance.", features: [ 'Tout du plan Starter', 'Badge "Vérifié" ✅', 'Jusqu\'à 10 Offres produits', 'Lien vers réseaux sociaux & Site Web', 'Statistiques de base (Vues)' ], offerLimit: 10, recommended: true, color: 'brand' }, { tier: Plan.EMPIRE, name: 'Empire', priceXOF: '13 000 FCFA', yearlyPriceXOF: '125 000 FCFA', priceEUR: '20€', yearlyPriceEUR: '192€', description: 'Dominez votre marché avec une visibilité maximale.', features: [ 'Tout du plan Booster', 'Badge "Recommandé" 🏆', 'Offres illimitées', 'Intégration vidéo Youtube', 'Interview écrite sur le Blog', 'Support prioritaire WhatsApp' ], offerLimit: 1000, recommended: false, color: 'amber' } ]; for (const planData of plans) { await prisma.pricingPlan.upsert({ where: { tier: planData.tier as any }, update: planData, create: planData, }); } console.log('Pricing plans seeded successfully.'); } main() .catch((e) => { console.error(e); process.exit(1); }) .finally(async () => { await prisma.$disconnect(); await pool.end(); });