cloudflare / cloudflare/developer-platform

Exporting and importing locally gives "no such table: main.User: SQLITE_ERROR"

Aperta
#9 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub
awaiting-response:cloudflare blocked 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.16.1

### Please provide a link to a minimal reproduction

_No response_

### Describe the Bug

I follow this article how to export and import d1.
https://developers.cloudflare.com/d1/best-practices/import-export-data/#export-an-existing-d1-database

```
npx wrangler d1 export xyz --remote --output=./database.sql
```

I remove `rm -rf .wrangler`

and then running
```
npx wrangler@latest d1 execute xyz-staging --file=database.sql
```

The sql file looks correct, but it looks like the export is not doing it correct in order

Image

You can see that _userOrganizations depends on User which has not been created yet, and if I switch the order then I get another SQL error about another table which does not exist.

### Please provide any relevant error logs

[wrangler-2025-05-23_10-58-30_040.log](https://github.com/user-attachments/files/20409177/wrangler-2025-05-23_10-58-30_040.log)

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con i comandi documentati `wrangler d1 export` e `wrangler d1 execute --file`, quindi esamina il `database.sql` generato e il log di Wrangler collegato. Verifica se le istruzioni delle tabelle esportate sono ordinate in modo sicuro in base alle loro dipendenze e considera completa l’importazione quando il file SQL viene eseguito correttamente sul database di staging.

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

Valutazione

Stack tecnologico
sql, sqlite
Ambito
databases
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 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.