fix(seed): safely handle blog upsert in try-catch block
Deploy Canina / deploy (push) Successful in 2m6s

This commit is contained in:
parsa aghaei committed 2026-07-29 15:49:39 +03:30
1 parent 84d9ed3a9d
commit bf60df34ef
1 file changed
+14 -5
+14 -5
View File
@@ -499,11 +499,20 @@ export async function main() {
];
for (const b of blogs) {
await prisma.blog.upsert({
where: { slug: b.slug },
update: {},
create: b,
});
try {
await prisma.blog.upsert({
where: { slug: b.slug },
update: {
title: b.title,
content: b.content,
isPublished: b.isPublished,
},
create: b,
});
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[Seed] Warning upserting blog ${b.slug}:`, msg);
}
}
console.log('Seeded blogs.');
}