修复种子脚本:更新已有板块的名称/描述/图标

This commit is contained in:
ZhuiGuangAI Dev
2026-05-30 21:53:27 +08:00
parent 7109af6dcd
commit 714f947b86
+21 -8
View File
@@ -162,19 +162,32 @@ async function createIndustryCategories() {
});
console.log(` + ${cat.name}`);
} else {
if (!childCat.parentId) {
await prisma.forumCategory.update({
where: { id: childCat.id },
data: { parentId: parent.id },
});
}
console.log(` ✓ ${cat.name} (exists)`);
await prisma.forumCategory.update({
where: { id: childCat.id },
data: {
name: cat.name,
icon: cat.icon,
description: cat.description,
sortOrder: cat.sortOrder,
parentId: parent.id,
},
});
console.log(` ↻ ${cat.name} (updated)`);
}
const existingSlugs = new Set(childCat.children.map(c => c.slug));
for (const sub of cat.children) {
if (existingSlugs.has(sub.slug)) {
console.log(` - ${sub.name} (exists)`);
await prisma.forumCategory.update({
where: { slug: sub.slug },
data: {
name: sub.name,
icon: sub.icon,
description: sub.description,
parentId: childCat.id,
},
});
console.log(` ↻ ${sub.name} (updated)`);
} else {
const conflictSlug = await prisma.forumCategory.findUnique({
where: { slug: sub.slug },