Using --local with workers and D1

Not sure if this is expected, or if I'm doing something wrong here... Having issues with getting a hello-world D1 Database setup using wrangler.jsonc and an explicit migrations_dir. I can't get migrations to be applied, even running explicitly. Running migrations apply, the wrong migration dir is being read (cf-iterate-test/branch-worker/migrations instead ofcf-iterate-test/branch-worker/apps/hello-world/database/migrations/0000_initial.sql)
wrangler d1 migrations apply HELLO_WORLD_DB --local

⛅️ wrangler 4.11.0 (update available 4.13.2)
-------------------------------------------------------

▲ [WARNING] No migrations folder found. Set `migrations_dir` in your wrangler.json file to choose a different path.

✘ [ERROR] No migrations present at /Users/user/Projects/cf-iterate-test/branch-worker/migrations.
wrangler d1 migrations apply HELLO_WORLD_DB --local

⛅️ wrangler 4.11.0 (update available 4.13.2)
-------------------------------------------------------

▲ [WARNING] No migrations folder found. Set `migrations_dir` in your wrangler.json file to choose a different path.

✘ [ERROR] No migrations present at /Users/user/Projects/cf-iterate-test/branch-worker/migrations.
Running execute HELLO_WORLD_DB, the DB isn't found.
wrangler d1 execute HELLO_WORLD_DB --local --file ./apps/hello-world/database/migrations/0000_initial.sql

⛅️ wrangler 4.11.0 (update available 4.13.2)
-------------------------------------------------------

✘ [ERROR] Couldn't find a D1 DB with the name or binding 'HELLO_WORLD_DB' in your wrangler.json file.
wrangler d1 execute HELLO_WORLD_DB --local --file ./apps/hello-world/database/migrations/0000_initial.sql

⛅️ wrangler 4.11.0 (update available 4.13.2)
-------------------------------------------------------

✘ [ERROR] Couldn't find a D1 DB with the name or binding 'HELLO_WORLD_DB' in your wrangler.json file.
The migrations definitely exist in the expected directory
ls apps/hello-world/database/migrations
0000_initial.sql
ls apps/hello-world/database/migrations
0000_initial.sql
The wrangler.jsonc definitely seems correct when compared to docs
cat wrangler.jsonc
{
"name": "branch-worker-local-dev",
"main": "src/index.ts",
"compatibility_date": "..",
"build": { ... }, "vars": {...},
"d1_databases": [
{
"binding": "HELLO_WORLD_DB",
"database_name": "local_local_hello-world_db_preview",
"database_id": "",
"preview_database_id": "local_local_hello-world_db_preview",
"migrations_dir": "./apps/hello-world/database/migrations"
}
],
"r2_buckets":[..]
}%
cat wrangler.jsonc
{
"name": "branch-worker-local-dev",
"main": "src/index.ts",
"compatibility_date": "..",
"build": { ... }, "vars": {...},
"d1_databases": [
{
"binding": "HELLO_WORLD_DB",
"database_name": "local_local_hello-world_db_preview",
"database_id": "",
"preview_database_id": "local_local_hello-world_db_preview",
"migrations_dir": "./apps/hello-world/database/migrations"
}
],
"r2_buckets":[..]
}%
I'm assuming database_id isn't needed when using --local?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?