Skip to main content

Using Prisma Migrate

Creating the database schema

In this guide, you'll use Prisma's db push command to create the tables in your database. Add the following Prisma data model to your Prisma schema in prisma/schema.prisma:

model Post {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
title String @db.VarChar(255)
content String?
published Boolean @default(false)
author User @relation(fields: [authorId], references: [id])
authorId Int


model Profile {
id Int @id @default(autoincrement())
bio String?
user User @relation(fields: [userId], references: [id])
userId Int @unique


model User {
id Int @id @default(autoincrement())
email String @unique
name String?
posts Post[]
profile Profile?

You are now ready to push your new schema to your database. Connect to your main branch using the instructions in Connect your database.

Now use the db push CLI command to push to the main branch:

npx prisma db push

Great, you now created three tables in your database with Prisma's db push command 🚀