Back to Prisma

push

apps/docs/content/docs/cli/db/push.mdx

latest2.3 KB
Original Source

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.

Usage

bash
prisma db push [options]

The datasource URL configuration is read from the Prisma config file (e.g., prisma.config.ts).

Prerequisites

Configure your database connection in prisma.config.ts:

prisma
generator client {
  provider = "prisma-client"
  output   = "../generated/prisma"
}

datasource db {
  provider = "sqlite"
}
typescript
import { defineConfig, env } from "prisma/config";

export default defineConfig({
  schema: "prisma/schema.prisma",
  migrations: {
    path: "prisma/migrations",
  },
  datasource: {
    url: env("DATABASE_URL"),
  },
});

Options

OptionDescription
-h, --helpDisplay help message
--configCustom path to your Prisma config file
--schemaCustom path to your Prisma schema
--urlOverride the datasource URL from the Prisma config file
--accept-data-lossIgnore data loss warnings
--force-resetForce a reset of the database before push

:::warning

In Prisma v7, db push no longer runs prisma generate automatically. Run it explicitly if needed.

:::

Examples

Push the schema to the database

npm
npx prisma db push

Accept data loss

Proceed even if the changes might result in data loss:

npm
npx prisma db push --accept-data-loss

Specify a schema path

npm
npx prisma db push --schema=/tmp/schema.prisma

Force reset before push

Reset the database before applying changes:

npm
npx prisma db push --force-reset

See also