From the course: Next.js Ecommerce: Build a Shopping Platform from Scratch

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Prisma models and migrations

Prisma models and migrations

OK, so now we're going to talk about Prisma models, which are extremely important because models, they're used to create your client, so basically the methods that you can use. And it's also used for migrations, which ultimately create the table and all the fields with specific types and constraints and stuff like that. Now, this documentation page shows you how to set up models. And you're going to do that within your schema.prisma file. So you have a schema with models in it. Sometimes I'll use schema and model interchangeably. But really, the whole thing together is your schema, and each one of these is a model. So as you can see, we define the model, and then we have whatever field we want, like an ID, and then the type. And then there's other annotations you can add, such as at ID, which will make it a primary key. You can add default values. There's certain functions like auto increment, So different things that you can add here. So what we're going to do is jump into…

Contents