Apply D1 migrations locally, then to remote

local dev

// what it does

Runs any unapplied migration files from your migrations dir against the local DB first, then promotes the same set to the production database once you've verified them. The standard schema-change loop for a D1-backed Worker.

// shell

$ wrangler d1 migrations apply <name> --local
$ wrangler d1 migrations apply <name> --remote

// gotcha

Forgetting --remote means production never changes — only your local copy migrates. Migrations are read from the migrations_dir bound to that database in config, so the DB name/binding must match exactly.