flnxi-Wu/scripts/migrate-ai-to-other-template.ts
WuYongJie 63ec6b7dfb fix: 修复排行榜按钮消失、tag排序和输入框浅色模式问题
1. 排行榜悬浮窗关闭后小按钮消失问题
   - 修复面板居中模式关闭时按钮位置错误
   - 保存并恢复按钮的居中状态

2. 首页tag按钮按素材数量排序
   - 添加按素材数量降序排序逻辑

3. 上传弹窗输入框浅色模式文字不可见
   - 添加 text-slate-900 确保浅色模式下文字可见
   - 添加 placeholder 样式确保占位符正确显示
2025-12-14 21:41:29 +08:00

75 lines
1.7 KiB
TypeScript

/**
* AI工作流模板素材迁移脚本
*
* 将使用 ai-material 模板的素材迁移到 other-material 模板
* 这是因为 ai-material 模板已被删除,替换为 audio-material
*
* 运行方式: npx ts-node scripts/migrate-ai-to-other-template.ts
*/
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
async function migrateAiMaterials() {
console.log('开始迁移 AI 工作流素材...')
// 查找使用 ai-material 模板的素材
const aiMaterials = await prisma.material.findMany({
where: {
OR: [
{ templateId: 'builtin-ai-material' },
{ materialType: 'AI 工作流' },
],
},
select: {
id: true,
productModel: true,
templateId: true,
materialType: true,
},
})
console.log(`找到 ${aiMaterials.length} 个 AI 工作流素材`)
if (aiMaterials.length === 0) {
console.log('没有需要迁移的素材')
return
}
// 批量更新素材
const updateResult = await prisma.material.updateMany({
where: {
OR: [
{ templateId: 'builtin-ai-material' },
{ materialType: 'AI 工作流' },
],
},
data: {
templateId: 'builtin-other-material',
materialType: '其他',
},
})
console.log(`成功迁移 ${updateResult.count} 个素材到 other-material 模板`)
// 输出迁移详情
console.log('\n迁移的素材列表:')
for (const material of aiMaterials) {
console.log(` - ${material.productModel} (ID: ${material.id})`)
}
}
async function main() {
try {
await migrateAiMaterials()
} catch (error) {
console.error('迁移失败:', error)
process.exit(1)
} finally {
await prisma.$disconnect()
}
}
main()