db 정의중

This commit is contained in:
koreacomp5
2025-10-08 23:44:21 +09:00
parent 39b5592c7d
commit 45cc1c0271
2 changed files with 188 additions and 19 deletions

View File

@@ -3,17 +3,52 @@ const { PrismaClient } = require("@prisma/client");
const prisma = new PrismaClient();
async function main() {
await prisma.user.upsert({
where: { email: "test@example.com" },
const user = await prisma.user.upsert({
where: { nickname: "tester" },
update: {},
create: {
email: "test@example.com",
nickname: "tester",
name: "Tester",
messages: {
create: [{ content: "Hello world" }, { content: "Second message" }]
}
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()