cloudflare / cloudflare/developer-platform

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

Offen
#9 7 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
awaiting-response:cloudflare blocked product:d1
Vorherrschende Sprache
Keine Sprachdaten
Sterne
1
Forks
0
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

### 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)

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start with the documented `wrangler d1 export` and `wrangler d1 execute --file` commands, then inspect the generated `database.sql` and the linked Wrangler log. Verify whether exported table statements are ordered safely for their dependencies, and consider the import complete when the SQL file executes successfully against the staging database.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
sql, sqlite
Bereich
databases
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.