Skip to main content
Prisma Documentation Docs

Search documentation

Type to search this documentation.

On this pageOverview

pull

The prisma db pull command connects to your database and adds Prisma models to your Prisma schema that reflect the current database schema.

prisma db pull [options]

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

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"),

  },

});
Flag Description
-h, --help Display help message
--force Ignore current Prisma schema file
--print Print the introspected Prisma schema to stdout
Option Description
--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
--composite-type-depth Depth for introspecting composite types (e.g., MongoDB Embedded Documents). Default -1 for infinite depth, 0 to disable
--schemas Specify database schemas to introspect (overrides datasource block)
--local-d1 Generate a Prisma schema from a local Cloudflare D1 database
title="bun"
bunx prisma db pull
pnpm
pnpm prisma db pull
yarn
yarn prisma db pull
npm
npx prisma db pull

Output:

Introspecting based on datasource defined in schema.prisma …

✔ Introspected 2 models and wrote them into schema.prisma in 38ms

Run prisma generate to generate Prisma Client.
title="bun"
bunx prisma db pull --schema=./alternative/schema.prisma
pnpm
pnpm prisma db pull --schema=./alternative/schema.prisma
yarn
yarn prisma db pull --schema=./alternative/schema.prisma
npm
npx prisma db pull --schema=./alternative/schema.prisma
title="bun"
bunx prisma db pull --print
pnpm
pnpm prisma db pull --print
yarn
yarn prisma db pull --print
npm
npx prisma db pull --print

Ignore any customizations in the current schema:

title="bun"
bunx prisma db pull --force
pnpm
pnpm prisma db pull --force
yarn
yarn prisma db pull --force
npm
npx prisma db pull --force
title="bun"
bunx prisma db pull --composite-type-depth=2
pnpm
pnpm prisma db pull --composite-type-depth=2
yarn
yarn prisma db pull --composite-type-depth=2
npm
npx prisma db pull --composite-type-depth=2
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu