DEV Community

Cover image for Zero-Config DB Setup with Drizzle ORM Using drizzle-setup CLI
Dev Gaurav Jatt
Dev Gaurav Jatt

Posted on

Zero-Config DB Setup with Drizzle ORM Using drizzle-setup CLI

๐Ÿ“š Supercharge Your Drizzle ORM Workflow with drizzle-setup CLI

Setting up a modern ORM for your project should be fast, reliable, and flexible. Thatโ€™s where drizzle-setup cli comes in โ€” a powerful utility to automatically scaffold your Drizzle ORM setup for PostgreSQL, SQLite, MySQL, and more.

Whether youโ€™re working on a side project or spinning up a production-ready stack, drizzle-setup ensures a frictionless experience from zero to fully-configured.


โœจ Why Use drizzle-setup?

Hereโ€™s what makes this CLI a game-changer:

  • ๐Ÿ“ฆ Zero Config Setup โ€“ Get started with just a few prompts.

  • ๐Ÿ“œ Drizzle Scripts โ€“ Automatically populates your package.json with useful Drizzle CLI commands.

  • ๐Ÿ”ง .env Auto Update โ€“ Adds all essential environment variables without manual hassle.

  • ๐Ÿงฉ Multi-DB Support โ€“ Works with PostgreSQL, SQLite, MySQL, and more.

  • ๐Ÿ“ Template Copying โ€“ Sets up your schema.ts and index.ts instantly.


๐Ÿ“ฆ Installation

You can install globally using your favorite package manager:

npm install -g drizzle-setup
# or use npx for one-time setup
npx drizzle-setup
Enter fullscreen mode Exit fullscreen mode

๐Ÿš€ Quick Start

In your project root, run:

drizzle-setup
Enter fullscreen mode Exit fullscreen mode

Youโ€™ll be guided through:

  1. Selecting a database (PostgreSQL, SQLite, etc.)

  2. Choosing a preset config

  3. Setting the target folder

  4. Copying boilerplate files

  5. Generating drizzle.config.ts

  6. Updating .env and package.json

  7. Installing required dependencies


๐Ÿงช Supported Databases

  • PostgreSQL: Default, Neon, PlanetScale and more.

  • SQLite: Default, Turso, Bun SQLite and more.

  • MySQL: Default, Turso, Bun SQLite and more.

Each choice is tailored with optimal templates and .env configs.


๐Ÿงฑ Resulting Directory Structure

Once setup completes, your project might look like this:

project-root/
โ”œโ”€โ”€ drizzle.config.ts
โ”œโ”€โ”€ .env
โ”œโ”€โ”€ [target-folder]/
โ”‚   โ”œโ”€โ”€ schema.ts
โ”‚   โ””โ”€โ”€ index.ts

Enter fullscreen mode Exit fullscreen mode

๐Ÿ”— Try it Now

Ready to skip the boilerplate and get building?

npx drizzle-setup
Enter fullscreen mode Exit fullscreen mode

๐Ÿ’ฌ Have Feedback?

Drop your suggestions or issues in the GitHub repo or tweet with the hashtag #DrizzleSetupCLI.


Top comments (3)

Collapse
 
dotallio profile image
Dotallio

Zero-config for Drizzle ORM is something Iโ€™ve definitely been wishing for. How does it hold up when switching between multiple DB environments in the same project?

Collapse
 
devgauravjatt profile image
Dev Gaurav Jatt

v0.0.5

โœจ feat(env): add support for multiple .env files

  • implemented support for updating multiple .env* files
  • added functionality to create a default .env file if none exist
  • improved handling of existing environment variables to avoid overwriting
  • enhanced error handling and logging for robustness
  • added glob package for file searching
  • updated documentation to reflect changes
Collapse
 
devgauravjatt profile image
Dev Gaurav Jatt

Some comments may only be visible to logged-in visitors. Sign in to view all comments.