From 080c488e3bb754cce08536ce66dece08107bb8e1 Mon Sep 17 00:00:00 2001 From: Beldor Date: Thu, 18 Jun 2026 13:23:28 -0300 Subject: [PATCH] fix: use PrismaPg adapter in seed.ts for Prisma 7 compatibility Co-Authored-By: Claude Sonnet 4.6 --- prisma/seed.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/prisma/seed.ts b/prisma/seed.ts index 8232a87..fe94e0c 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -1,7 +1,9 @@ import { PrismaClient } from "@prisma/client"; +import { PrismaPg } from "@prisma/adapter-pg"; import bcrypt from "bcryptjs"; -const prisma = new PrismaClient(); +const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL! }); +const prisma = new PrismaClient({ adapter }); async function main() { const hash = (pwd: string) => bcrypt.hash(pwd, 10); @@ -26,7 +28,6 @@ async function main() { }, }); - // Tipos de servicio de ejemplo const servicios = [ { nombre: "Cambio de aceite y filtro", duracionHoras: 1 }, { nombre: "Cambio de bujías", duracionHoras: 1 }, @@ -38,11 +39,8 @@ async function main() { ]; for (const s of servicios) { - await prisma.tipoServicio.upsert({ - where: { id: s.nombre }, - update: {}, - create: s, - }).catch(() => prisma.tipoServicio.create({ data: s })); + const existe = await prisma.tipoServicio.findFirst({ where: { nombre: s.nombre } }); + if (!existe) await prisma.tipoServicio.create({ data: s }); } console.log("Seed completado");