fix(seed): safely handle blog upsert in try-catch block
Deploy Canina / deploy (push) Successful in 2m6s
Deploy Canina / deploy (push) Successful in 2m6s
This commit is contained in:
1 parent
84d9ed3a9d
commit
bf60df34ef
1 file changed
+14
-5
@@ -499,11 +499,20 @@ export async function main() {
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const b of blogs) {
|
for (const b of blogs) {
|
||||||
await prisma.blog.upsert({
|
try {
|
||||||
where: { slug: b.slug },
|
await prisma.blog.upsert({
|
||||||
update: {},
|
where: { slug: b.slug },
|
||||||
create: b,
|
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.');
|
console.log('Seeded blogs.');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user