push (Prisma CLI v7)
Push the state from your Prisma schema to your database
The prisma db push command pushes the state of your Prisma schema to the database without using migrations. It creates the database if it does not exist.
This command is a good choice when you don't need to version schema changes, such as during prototyping and local development.
prisma db push [options]The datasource URL configuration is read from the Prisma config file (e.g., prisma.config.ts).
Prerequisites
Section titled “Prerequisites”Configure your database connection in prisma.config.ts:
generator client {
provider = "prisma-client"
output = "../generated/prisma"
}
datasource db {
provider = "sqlite"
}import { defineConfig, env } from "prisma/config";
export default defineConfig({
schema: "prisma/schema.prisma",
migrations: {
path: "prisma/migrations",
},
datasource: {
url: env("DATABASE_URL"),
},
});Options
Section titled “Options”| Option | Description |
|---|---|
-h, --help |
Display help message |
--config |
Custom path to your Prisma config file |
--schema |
Custom path to your Prisma schema |
--url |
Override the datasource URL from the Prisma config file |
--accept-data-loss |
Ignore data loss warnings |
--force-reset |
Force a reset of the database before push |
Examples
Section titled “Examples”Push the schema to the database
Section titled “Push the schema to the database”bunx prisma db pushpnpm prisma db pushyarn prisma db pushnpx prisma db pushAccept data loss
Section titled “Accept data loss”Proceed even if the changes might result in data loss:
bunx prisma db push --accept-data-losspnpm prisma db push --accept-data-lossyarn prisma db push --accept-data-lossnpx prisma db push --accept-data-lossSpecify a schema path
Section titled “Specify a schema path”bunx prisma db push --schema=/tmp/schema.prismapnpm prisma db push --schema=/tmp/schema.prismayarn prisma db push --schema=/tmp/schema.prismanpx prisma db push --schema=/tmp/schema.prismaForce reset before push
Section titled “Force reset before push”Reset the database before applying changes:
bunx prisma db push --force-resetpnpm prisma db push --force-resetyarn prisma db push --force-resetnpx prisma db push --force-reset