
Build a Fullstack Music App with Next.js Running the Seed Script
A second version of this course released using Next 13+, but this course is great if you want to see another example fullstack project. We now recommend you take the Build a Fullstack App with Next.js, v2 course.
Transcript from the "Running the Seed Script" Lesson
[00:00:00]
>> So now we have all of our artists that's going to be created. So what I'm gonna do is I'm just going to run this right quick, just to see if it works before we move on to the other part of the seed. And now I'm gonna show you what Prisma studio looks like, so you can actually explore your database within a visual app and see what's in there.
[00:00:18] So the way to run this is we want to go to our package.json, and all the way at the bottom, on the root of the objects, we wanna make a new field called prisma. Yeah, I know, they're so special, they get their own field in your package.json, and you want to run seed, and then there's a specific command for next js and prisma seed, so you gotta addd that.
[00:00:48] I'm gonna copy it. And basically, what this is gonna do is, it's literally prisma when it runs the migrate reset, which we haven't talked about, but it's just a migration that resets the whole database. It'll automatically run the prisma seed as well, you can also just run npx prisma seed and it'll run this command.
[00:01:14] So now that we have that, I'm gonna try to seed this thing and we'll see what breaks. If something breaks, then our schema was just completely off, so npx prisma db seed, sorry. So it's gonna attempt to seed this database. You can see right there, it says, the seed command has been executed, looks like no errors happened.
[00:01:37] So everything seems fine, to verify that I'm gonna type in npx prisma studio. That's gonna open up the browser and you can see here's a list of all of our models, so we get this nice little app here. And I'm gonna go look at artists, you can see it says I have five artists, there they are.
[00:01:57] And each artist has one song, except for this artist called FSM team, they have two songs. I can click on that and I can see the two songs that they have. So this is really cool, I thought this was awesome. I think every database needs some type of app like this.
[00:02:10] Most of them have something you gotta download on your computer and it either cost a lot of money and it's bad at the same time, or it's just not useful at all, super slow. I think the Mongo one was pretty cool. They had a community edition, it was actually really cool.
[00:02:26] It wasn't that bad. But yeah, this one's really cool, too. I think there's actually a plugin in VS code, too, that will connect to your database and show you your stuff in VS code, but it's just in pure JSON so hard to search and do things. But yeah, this one's really cool, so I like this.
[00:02:44] So yeah, there we go, I seed words. All of our stuff is in there. Everything's good to go.