Introspect an existing database and generate/refresh a Prisma schema from it using prisma db pull, then produce a working Prisma Client from the introspected schema.

domain: prisma.io · 7 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Set prisma.config.ts datasource.url to the database you want to introspect (env("DATABASE_URL")).
  2. Ensure prisma/schema.prisma at minimum has a `generator client { provider = "prisma-client" }` block and a `datasource db { provider = "<your-db>" }` block matching the real database type — db pull needs the provider to know how to read the database.
  3. Back up or commit the current prisma/schema.prisma first — db pull overwrites it and can discard manual customizations.
  4. Run `npx prisma db pull` to introspect and overwrite prisma/schema.prisma with models reflecting the live database. Use `npx prisma db pull --print` to preview the generated schema on stdout instead of writing it, or `--force` to discard any manual edits and regenerate purely from the introspected structure.
  5. Run `npx prisma generate` to build Prisma Client from the newly introspected schema.
  6. If you're introducing Prisma Migrate to this existing database afterward, don't just start running migrate dev — follow the baselining workflow (migrate diff + migrate resolve --applied) so Prisma doesn't try to recreate tables that already exist.
  7. Reference: https://www.prisma.io/docs/cli/db/pull, https://www.prisma.io/docs/orm/reference/prisma-cli-reference

Known gotchas

Related routes

Introspect a Cube data model and execute a query via the Cube REST API using the /v1/meta and /v1/load endpoints
cube.dev · 5 steps · unrated
Introspect (pull) an existing database's schema into a generated Drizzle TypeScript schema file, for a database-first workflow where the DB is the source of truth.
orm.drizzle.team · 8 steps · unrated
Prototype or sync a database schema directly from prisma/schema.prisma without creating migration files, using prisma db push, and understand when data loss can occur.
prisma.io · 7 steps · unrated

Give your agent this knowledge — and 17,200+ more routes

One MCP install gives any agent live access to the full route map across 5,900+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans