Skip to content

D1 executor

The @naxodev/nx-cloudflare:d1 executor runs wrangler d1 migrations <command> for a Worker’s D1 database. The plugin infers a d1 target for every d1_databases binding in a Worker’s wrangler.jsonc, exposing three Nx configurations — apply, create, and list — that set command for you. See Run D1 migrations for a task-oriented walkthrough.

Option Type Default Description
command apply | create | list (required) The D1 migrations subcommand. Supplied by the target's configuration.
databases object (required) Map of D1 binding name to database_name. Baked in by inference.
db string - Which D1 binding to target. Required when the Worker has multiple D1 databases.
remote boolean false Apply/list against the remote database (--remote) instead of local (--local).
env string - Cloudflare environment (--env).
message string - Migration message. Required for create.

command and databases are set by the inferred target’s configuration — you don’t pass them yourself.

Runs wrangler d1 migrations apply <database>. Applies pending migrations to the local database by default; pass --remote for the production database.

bunx nx run my-worker:d1:apply
bunx nx run my-worker:d1:apply --remote

Runs wrangler d1 migrations create <database> <message>. Scaffolds a new migration file. Requires --message.

bunx nx run my-worker:d1:create --message=add_users

Runs wrangler d1 migrations list <database>. Lists unapplied (pending) migrations. Uses the local database by default; pass --remote for production.

bunx nx run my-worker:d1:list
bunx nx run my-worker:d1:list --remote
  • D1 target inference is jsonc/json only — there is no TOML parser in the plugin, so wrangler.toml Workers do not get a d1 target.
  • When a Worker declares more than one d1_databases binding, pass --db=<binding> to select which one a command targets. With a single database, --db is optional; with multiple, omitting it errors and lists the valid bindings.
  • Arbitrary -- <wrangler flag> passthrough does not apply to this executor — only the typed options above (remote, env, message, db) are accepted.