cloudflare / cloudflare/developer-platform
Exporting and importing locally gives "no such table: main.User: SQLITE_ERROR"
- Lenguaje dominante
- Sin datos de lenguaje
- Estrellas
- 1
- Forks
- 0
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
### 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
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)
Guía de contribución
Línea de trabajo
Comienza con los comandos documentados `wrangler d1 export` y `wrangler d1 execute --file`, luego inspecciona el `database.sql` generado y el registro de Wrangler vinculado. Verifica si las sentencias de tabla exportadas están ordenadas de forma segura según sus dependencias, y considera la importación completa cuando el archivo SQL se ejecute correctamente contra la base de datos de staging.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- sql, sqlite
- Área
- databases
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100