sincecutoff.com
← all changes

wrangler D1 migrations_pattern selects migration files

Introduced 2026-06-05 · score 0.97

HOW TO USE IT

When D1 migrations use nested directories, set `migrations_pattern` in the binding and run `wrangler d1 migrations apply` or `wrangler d1 migrations list` for the database. The pattern must start with the configured `migrations_dir`; `migrations_pattern` is optional and defaults to `${migrations_dir}/*.sql`.

{ "d1_databases": [{ "binding": "DB", "database_name": "<DATABASE_NAME>", "database_id": "<UUID>", "migrations_dir": "migrations", "migrations_pattern": "migrations/*/migration.sql" }] }
npx wrangler d1 migrations apply <DATABASE>
npx wrangler d1 migrations list <DATABASE>

WHY THIS HELPS

Apply and list D1 migrations stored in nested layouts such as ORM-generated migration folders.

REQUIREMENTS AND LIMITATIONS

  • Version: 4.98.0
  • migrations_pattern: Glob for discovering migrations, relative to the Wrangler config file. `*` matches one path segment; `**` matches any number. Must start with `migrations_dir`.
  • migrations_dir (required): Required when `migrations_pattern` is set; pattern must start with this directory.
  • <DATABASE> (required): Database name or binding for the migration command.
  • Prerequisite: Set `migrations_dir` when configuring `migrations_pattern`.
  • Prerequisite: For a nested-only pattern, Wrangler's `migrations create` writes top-level files; generate new migrations using the ORM's command, such as `drizzle-kit generate`.
  • `migrations_pattern` is a glob relative to the Wrangler config file.
  • Files that do not match the pattern are not executed.
  • The default pattern is `${migrations_dir}/*.sql`, preserving today's behaviour.
  • When no migrations match the configured pattern but files matching `migrations/*/migration.sql` exist, Wrangler logs a hint suggesting `migrations_pattern` as an opt-in.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card