修复种子脚本:更新已有板块的名称/描述/图标
This commit is contained in:
@@ -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 },
|
||||
data: {
|
||||
name: cat.name,
|
||||
icon: cat.icon,
|
||||
description: cat.description,
|
||||
sortOrder: cat.sortOrder,
|
||||
parentId: parent.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log(` ✓ ${cat.name} (exists)`);
|
||||
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 },
|
||||
|
||||
Reference in New Issue
Block a user