import { PrismaClient } from '@prisma/client'; import { DEFAULT_PRODUCT_DETAIL_TEMPLATES } from './seeds/product-detail-templates.default'; const prisma = new PrismaClient(); async function main() { for (const tpl of DEFAULT_PRODUCT_DETAIL_TEMPLATES) { await prisma.commonProductDetailTemplate.upsert({ where: { code: tpl.code }, create: { code: tpl.code, name: tpl.name, description: tpl.description, aromaType: tpl.aromaType as 'QINGXIANG' | 'JIANGXIANG' | 'NONGXIANG' | null, storyTitle: tpl.storyTitle, storyText: tpl.storyText, features: tpl.features, detailImageUrls: [], suggestedDetailImageCount: tpl.suggestedDetailImageCount, sortOrder: tpl.sortOrder, status: 'ACTIVE', }, update: { name: tpl.name, description: tpl.description, aromaType: tpl.aromaType as 'QINGXIANG' | 'JIANGXIANG' | 'NONGXIANG' | null, storyTitle: tpl.storyTitle, storyText: tpl.storyText, features: tpl.features, detailImageUrls: [], suggestedDetailImageCount: tpl.suggestedDetailImageCount, sortOrder: tpl.sortOrder, }, }); } console.log(`Upserted ${DEFAULT_PRODUCT_DETAIL_TEMPLATES.length} product detail templates`); } main() .catch((e) => { console.error(e); process.exit(1); }) .finally(async () => { await prisma.$disconnect(); });