I think andrew is confused because D1 has a different API for it.
I think andrew is confused because D1 has a different API for it.
package.json scripts:CLOUDFLARE_API_TOKEN where I added a d1 read/write tokenD1_BINDINGWRANGLER_LOG=debug and hopefully you'll see what's going wrong WRANGLER_LOG=debug the other error was just too vague

env.DB.prepare(...) is just an object, it has almost nothing to do with SQLite. It is sent to your database, which makes a prepared statement with the SQL text and binds it with your parameters.prepare both times, of course)
14:28:29.976 > db:migrate-remote
14:28:29.976 > npx wrangler d1 migrations apply D1_BINDING --remote
14:28:29.976
14:28:31.315 ⛅️ wrangler 3.52.0
14:28:31.316 -------------------
14:28:32.030 Failed: Error while executing user command. Exited with error code: 1
14:28:32.040 Failed: build command exited with code: 1
14:28:33.462 Failed: error occurred while running build commandpackage.json scripts"postbuild": "npm run db:migrate-remote",
"db:migrate-remote": "npx wrangler d1 migrations apply D1_BINDING --remote",CLOUDFLARE_API_TOKEND1_BINDING17:09:38.403 > db:migrate-remote
17:09:38.403 > npx wrangler d1 migrations apply db-prod --remote
17:09:38.404
17:09:39.845 ⛅️ wrangler 3.52.0
17:09:39.845 -------------------
17:09:41.463 Failed: Error while executing user command. Exited with error code: 1
17:09:41.473 Failed: build command exited with code: 1
17:09:42.674 Failed: error occurred while running build commandWRANGLER_LOG=debugWRANGLER_LOG=debug17:21:21.937 🪵 Writing logs to "/opt/buildhome/.config/.wrangler/logs/wrangler-2024-04-26_15-21-21_813.log"
17:21:21.938 Failed to load .env file ".env": Error: ENOENT: no such file or directory, open '.env'
17:21:21.938 at Object.openSync (node:fs:603:3)
17:21:21.938 at Object.readFileSync env.DB.prepare(...)const stmt = db.prepare('SELECT * FROM users WHERE name = ?')
const user1 = stmt.bind("John Doe").first()
const user2 = stmt.reset().bind("Donald Duck").first()
const user3 = stmt.reset().bind("Mickey Mouse").first()