ts-pg-model generates TypeScript type definitions directly from a live PostgreSQL database by introspecting schemas, tables, columns, enums, and user-defined types. The current stable version is 2.0.39, with releases on GitHub and npm. Key differentiators: supports Postgres connection via URI or environment variable, dotenv integration, customizable naming conventions (change-case), target selection for schemas/tables/columns, and user-defined type mapping for JSON/UDTs. Output directory defaults to ./src/generated.
npm install ts-pg-modelNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Configuration file for ts-pg-model that connects to Postgres and generates TypeScript types in ./src/generated with camelCase conventions.
Set output.includeSchemaPath: true if you always want schema directory nesting.
Add file paths to output.keepFiles to prevent deletion.
Change export default config to export const config: Config = ...
Ensure you don't have a leftover .env value overriding your config.
Run npm install ts-pg-model --save-dev
Update config file to use named export: export const config: Config = { ... }Use Config<JsonTypeMap> instead of UserConfig<JsonTypeMap>