CLI
Durcno ships a command-line interface for project scaffolding, database interaction, and migration management.
- npm
- pnpm
- Bun
- Yarn
npx durcno <command> [options]
pnpm dlx durcno <command> [options]
bun x durcno <command> [options]
yarn dlx durcno <command> [options]
Commands
| Command | Description |
|---|---|
init | Initialize a new Durcno project |
shell | Open an interactive SQL REPL shell |
generate | Generate a new migration from schema changes |
migrate | Apply pending migrations |
push | Generate and apply a migration in one step |
down <migration> | Rollback a specific migration |
squash <start> <end> | Squash a range of migrations into one |
status | Show migration status |
Migration commands (generate, migrate, push, down, squash, status) are covered in the Migrations section.
init
Initialize a new Durcno project with an interactive setup wizard.
- npm
- pnpm
- Bun
- Yarn
npx durcno init [--force]
pnpm dlx durcno init [--force]
bun x durcno init [--force]
yarn dlx durcno init [--force]
Options
--force— Overwrite existing files without prompting.
What it does
The init command walks you through an interactive prompt to configure your project:
- Select a database connector — Choose from:
pg(node-postgres)postgres(postgres.js)bun(Bun SQL)pglite(WASM)
- Enter a connection URL — Your PostgreSQL connection string, or leave empty to use
process.env.DATABASE_URL! - Schema file path — Where to create your schema file (default:
db/schema.ts) - Migrations directory — Where to store migration files (default:
migrations) - Set
"type": "module"— Optionally update yourpackage.json(required for migration files)
Generated files
After completion, the following files are created:
durcno.config.ts— Database configuration filedb/schema.ts— Starter schema with an exampleUserstabledb/index.ts— Database query API
Example
- npm
- pnpm
- Bun
- Yarn
npx durcno init
pnpm dlx durcno init
bun x durcno init
yarn dlx durcno init
🚀 Durcno Project Setup
? Select a database connector: pg (node-postgres)
? Connection URL (leave empty to use process.env.DATABASE_URL!):
? Schema file: db/schema.ts
? Migrations directory: migrations
? Set "type": "module" in package.json? Yes
📄 Creating files ...
✔ Created durcno.config.ts
✔ Created db/schema.ts
✔ Created db/index.ts
✨ Project initialized successfully!
After initialization, follow the next steps printed in the terminal to generate and apply your first migration.
In non-interactive environments (CI, piped input), init uses default values automatically.
shell
Open an interactive SQL REPL connected to your database.
- npm
- pnpm
- Bun
- Yarn
npx durcno shell [--config path/to/durcno.config.ts]
pnpm dlx durcno shell [--config path/to/durcno.config.ts]
bun x durcno shell [--config path/to/durcno.config.ts]
yarn dlx durcno shell [--config path/to/durcno.config.ts]
Options
--config <path>— Path to the config file (defaults todurcno.config.ts).
Features
- Execute any SQL query directly against your database
- Multi-line input — queries are executed when they end with
; - Query results displayed in a formatted table
- Execution time reported for each query
- Command history (up to 100 entries)
Meta commands
The shell supports psql-style meta commands:
| Command | Description |
|---|---|
\dt, \d | List all tables |
\dn | List all schemas |
\du | List all roles |
\clear | Clear the screen |
\?, \help | Show available meta commands |
Example
- npm
- pnpm
- Bun
- Yarn
npx durcno shell
pnpm dlx durcno shell
bun x durcno shell
yarn dlx durcno shell
✔ Connected to database
DURCNO SHELL
Type SQL queries and press Enter to execute.
Enter "exit" or "quit" to close the shell.
durcno> SELECT * FROM "public"."users";
id | name | email
---+----------+-----------------
1 | John Doe | john@example.com
(1 row) (12.34ms)
durcno> \dt
Tables:
• public.users
durcno> exit
✔ Connection closed.
Press Ctrl+C during multi-line input to cancel the current query. Press Ctrl+C at the prompt to close the shell.