Generate TypeScript interfaces and constants from a Postgres database schema by querying pg_catalog. Version 4.2.0 requires TypeScript >=4.1. A fork of schemats that drops MySQL support in favor of deeper Postgres integration, supports table/column comments as JSDoc, custom JSON types via `--jsonTypesFile`, date-as-string mode, and schema name prefixing. Ships with a CLI tool and outputs both select and input interfaces plus runtime table constants.
npm install pg-ts-genNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Connects to Postgres and generates TypeScript interfaces and constants into dbschema.ts.
Upgrade Node.js to >=8.15.1 or use nvm to switch.
Install or upgrade TypeScript to >=4.1.
Use a different tool for MySQL schema generation.
Use --datesAsStrings flag if you prefer string types, and ensure pg types return strings.
Omit file extension in --jsonTypesFile value, e.g., --jsonTypesFile './db-types'
Use --jsonTypesFile (with 's').
Ensure dbschema.ts is included in your tsconfig.json files or use correct relative path.
Run via npx: npx pg-to-ts generate ...