const { PrismaClient } = require("@prisma/client"); const prisma = new PrismaClient(); async function main() { const user = await prisma.user.upsert({ where: { nickname: "tester" }, update: {}, create: { nickname: "tester", name: "Tester", birth: new Date("1990-01-01"), phone: "010-0000-0000", agreementTermsAt: new Date() } }); const board = await prisma.board.upsert({ where: { slug: "general" }, update: {}, create: { name: "General", slug: "general", description: "일반 게시판", sortOrder: 0 } }); const post = await prisma.post.create({ data: { boardId: board.id, authorId: user.userId, title: "첫 글", content: "Hello SQLite + Prisma", isPinned: false, status: "published" } }); await prisma.boardModerator.upsert({ where: { boardId_userId: { boardId: board.id, userId: user.userId } }, update: {}, create: { boardId: board.id, userId: user.userId, role: "MODERATOR" } }); await prisma.comment.createMany({ data: [ { postId: post.id, authorId: user.userId, content: "첫 댓글" }, { postId: post.id, authorId: user.userId, content: "두번째 댓글" } ] }); } main() .catch((e) => { console.error(e); process.exit(1); }) .finally(async () => { await prisma.$disconnect(); });