Database
Add PostgreSQL or MySQL with Drizzle in one command
Database
Use this command to scaffold Drizzle + a DB client (PostgreSQL or MySQL) into your Zuro project.
What This Command Does
When you run add database, Zuro:
- Installs DB dependencies.
- Generates DB files.
- Adds/updates
DATABASE_URLin.env. - Adds
DATABASE_URLvalidation inenv.ts. - Prints next steps (schema + migrations).
Command
npx zuro-cli add databasepnpm dlx zuro-cli add databasebun x zuro-cli add databaseSupported Module Inputs
You can call the database module with any of these:
database(interactive dialect picker)database-pgdatabase-mysqlpg,postgres,postgresqlmysql
Flags
Dedicated DB flags are not available yet.
Current practical options:
zuro-cli add databasefor interactive setupzuro-cli add database-pgorzuro-cli add database-mysqlto skip dialect selectionzuro-cli add database --helpto see command help
Interactive Flow
Pick A Dialect
? Which database dialect?
❯ PostgreSQL
MySQLEnter Database URL
Tip: Leave blank to use postgresql://postgres@localhost:5432/mydb
? Database URLDefaults:
- PostgreSQL:
postgresql://postgres@localhost:5432/mydb - MySQL:
mysql://root@localhost:3306/mydb
Install + Scaffold
CLI installs dependencies and generates DB files automatically.
What Gets Installed
| Dialect | Runtime deps | Dev deps |
|---|---|---|
| PostgreSQL | drizzle-orm, pg | drizzle-kit, @types/pg |
| MySQL | drizzle-orm, mysql2 | drizzle-kit |
Files Generated
index.ts
index.ts
env.ts
drizzle.config.ts
.env
drizzle.config.ts is generated at project root, and its schema path follows your configured srcDir (for example ./src/db/schema/*).
What To Expect After Running
Typical success output:
✔ database-pg added successfully!
📋 Next Steps:
1. Create schemas in src/db/schema/
2. Ensure the database exists
3. Run migrationsIf you left DB URL blank, you will also see a reminder to update DATABASE_URL.
First-Time Setup (Recommended)
- Add module:
npx zuro-cli add database - Create a schema file:
src/db/schema/posts.ts import { pgTable, text } from "drizzle-orm/pg-core"; export const posts = pgTable("posts", { id: text("id").primaryKey(), title: text("title").notNull(), }); - Export schema:
src/db/schema/index.ts export * from "./posts"; - Create DB and run migrations:
npx drizzle-kit generate npx drizzle-kit migrate
Environment Behavior
When you add a database module:
.envgetsDATABASE_URL=...- existing
DATABASE_URLis updated to your new value env.tsgetsDATABASE_URL: z.string().url()
Dialect Switching Safety
If your project already has one DB dialect and you add the other:
- Zuro warns before overwrite.
- Asks for confirmation.
- Creates a backup in
.zuro/backups/...before replacing DB files.
Troubleshooting
Invalid database URL: use a valid URL format (postgresql://...ormysql://...).Package manager ... not installed: install selected PM (pnpm,bun, etc.) or use npm.Failed during registry fetch: verify internet/registry URL and retry.Module not found: runnpx zuro-cli add database(ordatabase-pg/database-mysql).
URL Examples
| Database | URL |
|---|---|
| PostgreSQL local | postgresql://postgres@localhost:5432/mydb |
| PostgreSQL with password | postgresql://user:password@localhost:5432/mydb |
| MySQL local | mysql://root@localhost:3306/mydb |
| MySQL with password | mysql://root:password@localhost:3306/mydb |
| Neon | postgresql://user:pass@ep-xxx.neon.tech/mydb?sslmode=require |
| PlanetScale | mysql://user:pass@aws.connect.psdb.cloud/mydb?ssl=... |
Next Steps
npx zuro-cli add authpnpm dlx zuro-cli add authbun x zuro-cli add auth