cloudflare / cloudflare/developer-platform

D1 - Lowercase BEGIN for trigger definition on D1 migration or sql exec fails for remote but not locally

Aperta
#15 2 commenti 2 reazioni 0 assegnatari Vedi su GitHub
product:d1
Lingua principale
Nessun dato sulla lingua
Stelle
1
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### What versions & operating system are you using?

- wrangler 4.42.1
- node v24.9.0
- Ubuntu 24.04.2 LTS (WSL)

### Please provide a link to a minimal reproduction

_No response_

### Describe the Bug

I have a D1 migration `0002_create_triggers.sql` which create some triggers for the updated_at field on some tables. They were working fine locally, but upon running the migration remotely for my test environment the error below happens.

```
✘ [ERROR] incomplete input: SQLITE_ERROR [code: 7500]
```

After checking out some related issues I've tried messing around with my statements and found out that the `BEGIN` statement for my triggers definitions were the issue. I have the habit of writing sql statements in lowercase and have never imagined it would be an issue.

- Migration statement example that works locally but fails remotely:
```
create trigger if not exists update_user_updated_at
after update on user
for each row
begin
update user
set updated_at = current_timestamp
where id = OLD.id;
end;
```

- Migration statement that runs successfully on both local and remote:
```
create trigger if not exists update_user_updated_at
after update on user
for each row
BEGIN
update user
set updated_at = current_timestamp
where id = OLD.id;
end;
```

Tell me if there is any more info that would help debugging.

### Please provide any relevant error logs

```

--- 2025-10-16T20:11:22.611Z log
┌──────────────────────────┬────────┐
│ name │ status │
├──────────────────────────┼────────┤
│ 0002_create_triggers.sql │ ❌ │
└──────────────────────────┴────────┘

---

--- 2025-10-16T20:11:22.666Z error
✘ [ERROR] Migration 0002_create_triggers.sql failed with the following errors:

---

--- 2025-10-16T20:11:22.667Z log

---

--- 2025-10-16T20:11:22.668Z error
✘ [ERROR] incomplete input: SQLITE_ERROR [code: 7500]

---

--- 2025-10-16T20:11:22.678Z debug
Error: incomplete input: SQLITE_ERROR [code: 7500]
at Object.handler (REDACTED/.pnpm/wrangler@4.42.1_@cloudflare+workers-types@4.20251008.0/node_modules/wrangler/wrangler-dist/cli.js:154536:19)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Object.handler (REDACTED/.pnpm/wrangler@4.42.1_@cloudflare+workers-types@4.20251008.0/node_modules/wrangler/wrangler-dist/cli.js:152802:7)
---

--- 2025-10-16T20:11:22.678Z debug
Metrics dispatcher: Posting data {"deviceId":"47c...REDACTED","event":"wrangler command errored","timestamp":1760645482678,"properties":{"amplitude_session_id":1760645479237,"amplitude_event_id":1,"wranglerVersion":"4.42.1","osPlatform":"Linux","osVersion":"#1 SMP PREEMPT_DYNAMIC Thu Jun 5 18:30:46 UTC 2025","nodeVersion":24,"packageManager":"npm","isFirstUsage":false,"configFileType":"jsonc","isCI":false,"isPagesCI":false,"isWorkersCI":false,"isInteractive":true,"hasAssets":true,"argsUsed":["e","env","remote"],"argsCombination":"e, env, remote","command":"wrangler d1 migrations apply","args":{"env":"","e":"","remote":true,"xRemoteBindings":true,"preview":false,"database":""},"durationMs":3458,"durationSeconds":3.458,"durationMinutes":0.057633333333333335,"errorType":"UserError"}}
---

```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con 0002_create_triggers.sql e confronta il modo in cui la sua istruzione trigger viene elaborata durante l'esecuzione locale rispetto a quella remota delle migrazioni D1. Riproduci il caso di BEGIN in minuscolo usando l'SQL e l'errore forniti, quindi verifica il completamento confermando che la stessa migrazione venga applicata da remoto senza SQLITE_ERROR.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
sql, sqlite
Ambito
databases
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.