cloudflare / cloudflare/workerd
apply D1 migrations only fails in production
- Dominant language
- C++
- Stars
- 8.7k
- Forks
- 739
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 174
Description
We had a fairly complex migration with transactions, it ran fine locally but when we ran it in production, we got
```
π Running Wrangler Commands
/usr/local/bin/npx wrangler d1 migrations apply DB --remote
β
οΈ wrangler 4.43.0 (update available 4.45.0)
βββββββββββββββββββββββββββββββββββββββββββββ
Migrations to be applied:
βββββββββββββββββββββββββββββββββ
β name β
βββββββββββββββββββββββββββββββββ€
β 0003_sync_spending_limits.sql β
βββββββββββββββββββββββββββββββββ
? About to apply 1 migration(s)
Your database may not be available to serve requests during the migration, continue?
π€ Using fallback value in non-interactive context: yes
π Executing on remote database DB (25df52eb-95b6-4a4e-83aa-3880d1f1aff9):
π To execute on your local development database, remove the --remote flag from your wrangler command.
βββββββββββββββββββββββββββββββββ¬βββββββββ
β name β status β
βββββββββββββββββββββββββββββββββΌβββββββββ€
β 0003_sync_spending_limits.sql β β β
βββββββββββββββββββββββββββββββββ΄βββββββββ
β [ERROR] Migration 0003_sync_spending_limits.sql failed with the following errors:
β [ERROR] To execute a transaction, please use the state.storage.transaction() or state.storage.transactionSync() APIs instead of the SQL BEGIN TRANSACTION or SAVEPOINT statements. The JavaScript API is safer because it will automatically roll back on exceptions, and because it interacts correctly with Durable Objects' automatic atomic write coalescing. [code: 7500]
πͺ΅ Logs were written to "/home/runner/.config/.wrangler/logs/wrangler-2025-10-24_22-40-25_842.log"
```
This should absolutely have failed locally if you're going to fail it in production.
Contributor guide
Assessment
This issue has not been assessed yet.