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
Configure `drizzle.config.ts` with `dialect` and `dbCredentials` — `schema` is not required for pull. `out` controls where the generated schema is written (default `./drizzle`).
Run `npx drizzle-kit pull` (or with CLI-only flags: `npx drizzle-kit pull --dialect=postgresql --url=postgresql://user:password@host:port/dbname`).
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(), ... })`.
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.
Control generated in-code column/key casing with `introspect: { casing: "camel" | "preserve" }` in config (default `"camel"`).
Scope introspection with `tablesFilter`, `schemaFilter` (both default `"*"`), and `extensionsFilters` (default `[]`) — e.g. exclude a `postgis`-managed table set: `extensionsFilters: ["postgis"]`.
For non-standard drivers (`aws-data-api`, `pglite`, `d1-http`) set `driver` explicitly with the matching `dbCredentials` shape.
Unlike `generate`/`push`, `pull` does not require a `schema` config key — it only needs `dialect` and connection credentials.
Default introspect casing is `"camel"`, which converts DB column names to camelCase in-code property names while preserving the actual DB column name via an explicit name argument — switch to `"preserve"` if you want in-code keys to exactly match DB names (including hyphens/underscores).
Default `tablesFilter`/`schemaFilter` is effectively all tables in all schemas, so pulling can include extension-created tables (e.g. from `postgis`) unless excluded via `extensionsFilters`.
`--init` matters specifically for onboarding an existing database into the `generate`/`migrate` workflow without Drizzle Kit trying to regenerate the entire schema as a fresh "initial" migration.
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?