Skip to main content
bunny db provides full lifecycle management for Bunny Database: creating databases, linking them to local projects, running SQL interactively, applying schema migrations, generating auth tokens, and viewing tables in a browser.

Database resolution

Most db commands accept an optional <database-id> positional argument. When omitted, the CLI resolves the target in this order:
  1. Explicit <database-id> argument
  2. .bunny/database.json manifest written by bunny db link
  3. BUNNY_DATABASE_URL in a .env file (walked up from the current directory) matched against your database list
  4. Interactive selection prompt
For bunny db shell, the CLI also reads BUNNY_DATABASE_AUTH_TOKEN from .env to skip token generation. Both variables can be written automatically by bunny db create or bunny db quickstart.

bunny db create

Create a new database. Interactively prompts for name and region selection (automatic, single region, or manual) when flags are omitted. After creation, prompts to link the directory, generate an auth token, and save credentials to .env.
In --output json mode, prompts are suppressed entirely. Flags are the only way to opt in to linking, token creation, and .env writes. The JSON output gains linked, token, and saved_to_env fields reflecting what happened.

bunny db list

List all databases. Shows ID, name, status, primary region, and size.

bunny db show

Show details for a single database.
Link the current directory to a database. Writes { id, name } to .bunny/database.json so subsequent db commands resolve the target without BUNNY_DATABASE_URL in .env. With no argument, lists all databases for interactive selection.
bunny db create offers to link the new database, and bunny db delete automatically removes a stale link when it points at the deleted database.

bunny db delete

Permanently delete a database. Requires double confirmation (or --force to skip).

bunny db regions

Manage primary and replica regions for a database.

bunny db regions list

bunny db regions add

bunny db regions remove

bunny db regions update

Interactively update region configuration. Shows all available regions with current ones pre-selected. Toggle on/off and confirm.

bunny db usage

Show usage statistics for a database.

bunny db quickstart

Generate a quickstart guide for connecting to a database from your preferred language.

bunny db shell

Open an interactive SQL shell for a database. Supports multiple output modes, sensitive column masking, persistent history, and dot-commands for quick introspection.
When no --token is supplied and BUNNY_DATABASE_AUTH_TOKEN is not set, the shell session is active for 30 minutes. Re-run the command to reconnect, or pass --token / set BUNNY_DATABASE_AUTH_TOKEN to use your own credentials.

Dot-commands

Available in interactive mode:

Sensitive column masking

Columns matching patterns like password, secret, api_key, auth_token, ssn, etc. are masked by default (********). Email columns are partially masked (a••••e@example.com). Use .unmask or the --unmask flag to reveal values.

bunny db studio

Open a read-only table viewer in your browser. Spins up a local server, generates a short-lived auth token if needed, and opens the studio UI.

bunny db migrations

Create and apply versioned SQL migrations. Migration files live on disk, run in filename order, and carry a tracking row in the database, so the CLI applies each file exactly once. See Migrations for the full workflow, including ORM output and running migrations in CI.

bunny db migrations create

Create an empty, numbered migration file. The filename is the migration’s identity, so the numeric prefix decides the order apply runs them in.
Aliased as bunny db migrations new. Creation never auto-detects an ORM output directory: writing a hand-authored file there would bypass the ORM’s own journal. The new file holds only a comment, so add SQL before applying it. apply rejects a migration with no statements.

bunny db migrations list

Show which migrations have been applied. Read-only: it never creates the tracking table.
Aliased as ls and status. Each migration is reported in one of five states:

bunny db migrations apply

Apply every pending migration, in filename order. Each file runs as one atomic batch together with its tracking row, so a migration either lands and is recorded or neither happens. Foreign keys are deferred for the batch, so table rebuilds work. The run stops at the first failure and leaves the remaining migrations pending.
A dry run and a declined confirmation both leave the database untouched, including the tracking table. Against a drifted history, apply refuses and applies nothing until you pass --allow-drift. The CLI only prompts for confirmation when stdin is an interactive terminal, so CI runs don’t hang. The CLI records applied migrations in a __bunny_migrations table. The __ prefix keeps it out of studio and REST introspection. When migrations/ doesn’t exist and you pass no --dir, the CLI falls back to drizzle/ if it’s present, so drizzle-kit generate output works with no configuration. Every migration file is parsed before the first database write, so a malformed later file cannot leave a run half-complete.

bunny db tokens

Generate and invalidate database auth tokens.

bunny db tokens create

Generate an auth token for a database. The database ID can be provided as a positional argument or auto-detected from BUNNY_DATABASE_URL in a .env file.

bunny db tokens invalidate

Invalidate all auth tokens for a database. Prompts for confirmation unless --force is passed.
Last modified on September 4, 2026