import 'dotenv/config'; import { prisma } from '../lib/prisma'; import { MOCK_BLOG_POSTS, MOCK_INTERVIEWS } from '../lib/mockData'; async function main() { console.log('--- Migration des données Mock vers la DB ---'); // 1. Migration des BlogPosts console.log('Migration des BlogPosts...'); for (const post of MOCK_BLOG_POSTS) { await prisma.blogPost.upsert({ where: { id: post.id }, update: {}, create: { id: post.id, title: post.title, excerpt: post.excerpt, content: post.content, author: post.author, imageUrl: post.imageUrl, date: new Date(post.date) } }); } // 2. Migration des Interviews console.log('Migration des Interviews...'); for (const interview of MOCK_INTERVIEWS) { await prisma.interview.upsert({ where: { id: interview.id }, update: {}, create: { id: interview.id, title: interview.title, guestName: interview.guestName, companyName: interview.companyName, role: interview.role, type: interview.type, thumbnailUrl: interview.thumbnailUrl, videoUrl: interview.videoUrl, content: interview.content, excerpt: interview.excerpt, duration: interview.duration, date: new Date(interview.date) } }); } console.log('Migration terminée avec succès !'); } main() .catch((e) => { console.error(e); process.exit(1); }) .finally(async () => { await prisma.$disconnect(); });