// prisma/seed.js const { PrismaClient } = require("@prisma/client"); const prisma = new PrismaClient(); async function main() { console.log("🌱 Seeding database…"); const course = await prisma.course.upsert({ where: { code: "ANIM101" }, update: {}, create: { code: "ANIM101", title: "3D Animation | Character Design", description: "Introductory course for animation students.", }, }); await prisma.playlist.create({ data: { title: "Introduction to Character Design", description: "Basic foundations and workflow.", sortOrder: 0, courseId: course.id, videos: { create: [ { title: "Welcome + Overview", index: 0, durationSec: 300, url: "/videos/test.mp4", thumbnail: "/01.jpg" }, { title: "Understanding Silhouette", index: 1, durationSec: 420, url: "/videos/test.mp4", thumbnail: "/01.jpg" }, { title: "Gesture & Appeal", index: 2, durationSec: 380, url: "/videos/test.mp4", thumbnail: "/01.jpg" }, ], }, }, }); await prisma.playlist.create({ data: { title: "Advanced Character Techniques", description: "Secondary forms, expression & posing.", sortOrder: 1, courseId: course.id, videos: { create: [ { title: "Secondary Motion", index: 0, durationSec: 400, url: "/videos/test.mp4", thumbnail: "/01.jpg" }, { title: "Expressions & Acting Choices", index: 1, durationSec: 600, url: "/videos/test.mp4", thumbnail: "/01.jpg", locked: true }, { title: "Polish & Finishing", index: 2, durationSec: 500, url: "/videos/test.mp4", thumbnail: "/01.jpg" }, ], }, }, }); const user = await prisma.user.upsert({ where: { email: "student@example.com" }, update: {}, create: { email: "student@example.com", name: "Test Student", }, }); await prisma.enrollment.upsert({ where: { userId_courseId: { userId: user.id, courseId: course.id } }, update: {}, create: { userId: user.id, courseId: course.id, }, }); console.log("🌱 Seed complete!"); } main() .catch((e) => { console.error(e); }) .finally(() => prisma.$disconnect());