Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Prisma · Command

prisma db pull

prisma db pull introspects a database and updates the Prisma schema with models matching its current structure. It reads the connection configuration from Prisma config and supports options for selecting, printing, or replacing schema output.

How it works

The command reads the datasource connection from Prisma configuration, connects to the database, inspects its structure, converts that structure into Prisma schema models, and writes the result to the schema file. Use options to select a different schema or URL, print instead of write, or disregard the existing schema.

Syntax

prisma db pull [options]

Parameters

NameTypeDescription
optionsobjectOptional command flags such as --force, --print, --config, --schema, --url, --schemas, and connector-specific options.

Returns

Writes the introspected Prisma schema to the configured or selected schema file, or prints it to stdout when --print is used.

Key points

  • Use this command to bring the database's current structure into the Prisma schema.
  • It creates or updates Prisma models that represent the database schema.
  • Configure the database connection in prisma.config.ts before running the command.
  • Use --force when the introspected database should completely replace the existing schema model.
  • Use --print to inspect generated schema output without directing it to the schema file.
  • For databases supporting multiple schemas, --schemas selects which database schemas to inspect.

Common mistakes

  • Running the command can replace the current schema, so commit or back up important manual changes first.
  • For MongoDB, introspection samples data rather than reading a database schema.

Example: Introspect a database into a selected schema file

prisma db pull --schema=./prisma/schema.prisma

Introspects the configured database and writes the resulting Prisma schema to the specified schema file.

When to use it

Generate an initial Prisma schema

Adopting Prisma for an existing relational database.

Synchronize schema changes

A database was changed with SQL or another migration system.

Preview introspection output

You need to inspect generated schema without modifying the file.

Select schemas to introspect

A project uses multiple database schemas.

Interview questions

QWhat does prisma db pull do?

It connects to the configured database, introspects its current structure, converts that structure into Prisma models, and writes the result to the Prisma schema. The datasource URL comes from the Prisma config file.

Follow-up: How would you intentionally discard existing schema customizations? Use --force, which makes the generated schema solely from introspection and ignores the existing Prisma schema.

QWhat risk does the command pose to an existing schema?

The command can merge database changes with an existing relational Prisma schema, but it may overwrite the schema file. Important manual changes should therefore be committed or backed up before running it.

Follow-up: What should follow a successful pull in an application using Prisma Client? Run prisma generate so the client reflects the updated schema.

QWhich options are commonly useful with this command?

The basic syntax is prisma db pull [options]. Useful options include --print to send the introspected schema to standard output, --force to ignore the current schema, and --schema to choose another schema path.

Follow-up: How can the connection target be changed without editing the config? Supply --url to override the datasource URL from the Prisma config.

  • prisma generate
  • prisma db push
  • prisma db execute
  • prisma.config.ts
  • --force
  • --print
  • --schema
  • --url

Source: prisma db pull | Prisma Documentation. Checked 2026-10-16.