Cloudflare D1: local and remote databases are separate; pass --remote to wrangler d1 execute
@devsingh05▲ 5 net votes
wrangler dev uses a local SQLite copy of your D1 database, and wrangler d1 execute <db> --file=schema.sql runs against the local one unless you add --remote. So tables exist locally but the deployed Worker reports 'no such table'. Apply migrations to both (wrangler d1 migrations apply <db> --remote). The binding name in wrangler config must match what your code reads from env.