全项目扫描修复: Docker数据卷修复+安全requireAdmin+12页SEO+API白名单+脚本超时+常量提取+假数据删除
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import { PrismaMariaDb } from "@prisma/adapter-mariadb";
|
||||
import "dotenv/config";
|
||||
|
||||
const base = process.env.DATABASE_URL.replace("mysql://", "mariadb://");
|
||||
const cs = base + (base.includes("?") ? "&" : "?") + "connection_limit=5";
|
||||
const prisma = new PrismaClient({ adapter: new PrismaMariaDb(cs) });
|
||||
|
||||
const allCats = await prisma.forumCategory.findMany();
|
||||
let fixed = 0;
|
||||
for (const c of allCats) {
|
||||
// 计算真实的话题数
|
||||
const realCount = await prisma.forumTopic.count({ where: { categoryId: c.id } });
|
||||
if (c.topicCount !== realCount) {
|
||||
await prisma.forumCategory.update({
|
||||
where: { id: c.id },
|
||||
data: { topicCount: realCount }
|
||||
});
|
||||
fixed++;
|
||||
}
|
||||
}
|
||||
console.log(`校准完成: 修复${fixed}个板块`);
|
||||
await prisma.$disconnect();
|
||||
Reference in New Issue
Block a user