D1 is empty

Hi All, I am facing an issue using D1 locally. The issue is my worker cannot see any of the DB objects I have created.

First, I setup my DB with some DDL:

wrangler d1 execute appdb-dev --local --file=./1.sql

Then I can query the DB:

wrangler d1 execute appdb-dev --local --command="SELECT * FROM User" // works

However, when I try to access my local d1 instance in the worker, it can't find any tables. It is obviously looking at some other local instance, but I can't find any way to list the local instances, or don't know the commands to understand whether I am looking at the right one.

Any ideas? Wrangler.toml below:

name = "app-services"
compatibility_date = "2023-12-01"
route = "api.myapp.app/*"
compatibility_flags = ["nodejs_compat"]

[vars]
LOG_LEVEL="debug"
TEST_MODE="TRUE"
kv_namespaces = [
{ binding = "MYAPP_TOKENS", preview_id = "###", id = "###" },
]

[[d1_databases]]
binding = "DB"
database_name = "appdb-dev"
database_id = "###"
preview_database_id = "appdb-dev"

[env.dev]
route = "dev-api.myapp.app
Was this page helpful?