const { PrismaClient } = require('@prisma/client'); const prisma = new PrismaClient(); async function clearBookChapters() { try { console.log('🗑️ 清空 bookId=1 的所有章节数据...'); const result = await prisma.bookChapter.deleteMany({ where: { bookId: 1 } }); console.log(`✅ 已删除 ${result.count} 条章节记录`); // 重置书籍状态 await prisma.book.update({ where: { id: 1 }, data: { status: 'draft', progress: 0, errorMsg: null } }); console.log('✅ 书籍状态已重置为 draft'); } catch (error) { console.error('错误:', error); } finally { await prisma.$disconnect(); } } clearBookChapters();