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.
Options
Section titled “Options”| 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.
Configurations
Section titled “Configurations”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
create
Section titled “create”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.tomlWorkers do not get ad1target. - When a Worker declares more than one
d1_databasesbinding, pass--db=<binding>to select which one a command targets. With a single database,--dbis 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.
Next steps
Section titled “Next steps”- Run D1 migrations — step-by-step guide
- binding generator — add the D1 binding this executor operates on
- Inferred targets — the full target reference