Prisma expects you to define the shape of your data in the schema.prisma file

notion image

If your final app will have a Users table, it would look like this in the schema.prisma file

model User {
  id         Int      @id @default(autoincrement())
  username   String   @unique
  password   String
  firstName  String
  lastName   String
}

Assignment

Add a Users and a Todo table in your application. Don’t worry about foreign keys / relationships just yet

notion image

Generate migrations

You have created a single schema file. You haven’t yet run the CREATE TABLE commands. To run those and create migration files , run

npx prisma migrate dev --name Initialize the schema

Your DB should now have the updated schema.

💡

Check the prisma/migrations folder and check if you see anything interesting in there

Exploring your database

If you have psql , try to explore the tables that prisma created for you.

psql -h localhost -d postgres -U postgres

notion image

Generating the prisma client