Files
2026-08-16 17:18:23 +03:00

53 lines
1.4 KiB
TypeScript

import { PrismaClient } from "@prisma/client";
import { INITIAL_POSTS } from "../components/mockData";
const prisma = new PrismaClient();
async function main() {
console.log("Seeding database with initial posts...");
for (const post of INITIAL_POSTS) {
await prisma.post.upsert({
where: { id: post.id },
update: {
title: post.title,
content: post.content,
likes: post.likes,
},
create: {
id: post.id,
type: post.type,
date: post.date,
timestamp: post.timestamp,
mood: post.mood as any,
moodLabel: post.moodLabel,
title: post.title,
content: post.content,
marginNotes: post.marginNotes || [],
tags: post.tags || [],
likes: post.likes || 0,
highlightWords: post.highlightWords || [],
authorNote: post.authorNote,
imageUrl: post.imageUrl,
imageCaption: post.imageCaption,
codeSnippet: post.codeSnippet,
codeLanguage: post.codeLanguage,
audioDuration: post.audioDuration,
audioTitle: post.audioTitle,
stampedText: post.stampedText,
},
});
}
console.log("Seeding completed successfully!");
}
main()
.catch((e) => {
console.error("Error during seeding:", e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});