From the course: Master Next.js by Building Scalable Apps with Routing, Databases, and Performance

Unlock this course with a free trial

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

Creating buyer table in the database

Creating buyer table in the database

For the authentication buyers in the client section, we will need a separate table to store the buyer data into the database. So we will create a buyer master table in the database where all the buyer's data is stored. So in the admin application, I'll open the schema.prisma file and add the buyer master model by saying model buyer master, id with int at id and the default will be auto increment. Then the customer name with string, e-mail string, which is going to be a unique value. Then I will add password with the string data type and I will add optional fields for address and city and both of them are strings. And finally, created at date time where the default will be the current date and time with the now function. Alright, the model is created. Now let's generate the tables in the database. So I will open the terminal and we'll write npx prisma migrate dev. And it asks for migration name. So I will say added buyer master. And now the schema updates are synced. Let's open the dev…

Contents