import { PrismaClient } from "@prisma/client"; import bcrypt from "bcryptjs"; const prisma = new PrismaClient(); async function main() { const adminEmail = process.env.ADMIN_EMAIL || "pierre@secourit.fr"; const adminPassword = process.env.ADMIN_PASSWORD || "JuanitoAdmin2026!"; const existing = await prisma.user.findUnique({ where: { email: adminEmail }, }); if (!existing) { const hashed = await bcrypt.hash(adminPassword, 10); await prisma.user.create({ data: { email: adminEmail, name: "Juanito", password: hashed, role: "ADMIN", muayThai: { create: {} }, }, }); console.log(`✅ Admin créé: ${adminEmail}`); } else { console.log(`Admin existe déjà: ${adminEmail}`); } // Créer les tiers Yoga par défaut const tiers = [ { name: "Séance unique", numberOfSessions: 1, priceTotal: 9 }, { name: "Pack 5 séances", numberOfSessions: 5, priceTotal: 40 }, { name: "Pack 10 séances", numberOfSessions: 10, priceTotal: 70 }, ]; for (const t of tiers) { const exists = await prisma.yogaTier.findFirst({ where: { name: t.name }, }); if (!exists) { await prisma.yogaTier.create({ data: t }); console.log(`✅ Tier yoga créé: ${t.name}`); } } console.log("Seed terminé ✅"); } main() .catch((e) => { console.error(e); process.exit(1); }) .finally(async () => { await prisma.$disconnect(); });