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.

domain: orm.drizzle.team · 8 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Configure `drizzle.config.ts` with `dialect` and `dbCredentials` — `schema` is not required for pull. `out` controls where the generated schema is written (default `./drizzle`).
  2. Run `npx drizzle-kit pull` (or with CLI-only flags: `npx drizzle-kit pull --dialect=postgresql --url=postgresql://user:password@host:port/dbname`).
  3. Drizzle Kit queries the database DDL and writes a `schema.ts` file (plus snapshot files) into the `out` folder, e.g. producing `export const users = p.pgTable("users", { id: p.serial().primaryKey(), ... })`.
  4. Optionally pass `--init` (`npx drizzle-kit pull --init`) to mark the pulled schema as an already-applied migration baseline, so future `generate`/`migrate` runs diff against this initial pull instead of an empty state.
  5. Control generated in-code column/key casing with `introspect: { casing: "camel" | "preserve" }` in config (default `"camel"`).
  6. Scope introspection with `tablesFilter`, `schemaFilter` (both default `"*"`), and `extensionsFilters` (default `[]`) — e.g. exclude a `postgis`-managed table set: `extensionsFilters: ["postgis"]`.
  7. For non-standard drivers (`aws-data-api`, `pglite`, `d1-http`) set `driver` explicitly with the matching `dbCredentials` shape.
  8. Reference: https://orm.drizzle.team/docs/drizzle-kit-pull https://orm.drizzle.team/docs/migrations https://orm.drizzle.team/docs/drizzle-config-file

Known gotchas

Related routes

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.
prisma.io · 7 steps · unrated
Prototype rapidly by pushing a Drizzle TypeScript schema's current shape directly to a database with `drizzle-kit push`, skipping SQL migration file generation entirely.
orm.drizzle.team · 7 steps · unrated
Prototype rapidly by pushing a Drizzle TypeScript schema's current shape directly to a database with `drizzle-kit push`, skipping SQL migration file generation entirely.
orm.drizzle.team · 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