fix: use PrismaPg adapter in seed.ts for Prisma 7 compatibility
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+5
-7
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user