npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gen-types-enums-psql-schema

v1.3.1

Published

A CLI tool to automatically generate TypeScript types and enums from any PostgreSQL DB schema

Readme

Node.js language OS npm version GitHub last commit License Free

⭐ Star us on GitHub — let's reach 10 stars together! 😊

🔥 Why use this tool? — Read the docs 📑

Table of Contents

🚀 About

gen-types-enums-psql-schema is a CLI tool to automatically generate TypeScript types and enums from any PostgreSQL DB schema using Drizzle ORM. It streamlines the process of keeping your TypeScript types in sync with your database schema, improving type safety and developer productivity.

  • Modular: Works with any PostgreSQL schema.
  • TypeScript-first: Generates enums and types with proper naming conventions.
  • Flexible: Supports full and types-only generation modes.
  • Automated: Cleans up, lints, and organizes output for you.

✨ Features

  • Configurable: Works with any PostgreSQL schema, not just a specific one.
  • TypeScript Enums: Generates properly formatted TypeScript enums for each database enum.
  • Type Safety: Creates TypeScript types for all tables with proper naming conventions.
  • Flexible Modes: Provides both full and types-only modes for different workflows.
  • Code Quality: Automatically fixes code style issues with ESLint.
  • Clean Output: Streamlines development workflow by automating types generation.

📦 Installation

Global

npm install -g gen-types-enums-psql-schema

Local

npm install gen-types-enums-psql-schema
npx gen-types-enums-psql-schema --help

With Bun (Recommended)

Global

bun install -g gen-types-enums-psql-schema

Local

bun add gen-types-enums-psql-schema
bunx gen-types-enums-psql-schema --help

🚦 Usage

# Full process - pull schema from database and generate types
gen-types-enums-psql-schema <schema_name>

# Only regenerate types from existing schema (without querying the database)
gen-types-enums-psql-schema <schema_name> --types-only

# Pull and generate types for all schemas
gen-types-enums-psql-schema --all

# Remove schema.ts after enum generation
gen-types-enums-psql-schema <schema_name> --remove-schema

# Skip ESLint step
gen-types-enums-psql-schema <schema_name> --disable-eslint

# Show help
gen-types-enums-psql-schema --help

Shell Script Wrapper

A shell script wrapper is provided for easier usage:

./gen-types-enums.sh <schema_name> [flags]

⚙️ Configuration

Environment Variables

  • DATABASE_URL - PostgreSQL connection string (required for schema pull)
export DATABASE_URL="postgresql://username:password@localhost:5432/database_name"

Database Config Files

The tool creates schema-specific config files like db.config.public.ts for the public schema, based on the template in db.config.ts. Existing config files are not overwritten.

📂 Generated Files

For a schema named public, the following files will be generated:

./schemas/
├── public/
│ ├── schema.ts
│ ├── types.ts
│ ├── enums.ts
│ └── index.ts

📚 Documentation

🤝 Feedback and Contributions

We welcome feedback, feature requests, and contributions!

Your input helps us improve and grow the project!

🗨️ Runing Into Errors?

Feel free to reach me out here or just mail me at [email protected]. Check the GitHub Issues. If an issue does not exist, feel free to create a new one.

LinkedIn Twitter Follow

📃 License

MIT © Harjot Singh Rana
Free for non-commercial use.

Back to top