cloudflare / cloudflare/developer-platform
Exporting and importing locally gives "no such table: main.User: SQLITE_ERROR"
- 主要言語
- 言語のデータがありません
- スター
- 1
- フォーク
- 0
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
### 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)
コントリビューションガイド
調査の方向性
ドキュメント化された `wrangler d1 export` と `wrangler d1 execute --file` コマンドから始め、生成された `database.sql` とリンクされた Wrangler ログを確認します。エクスポートされたテーブルのステートメントが依存関係に対して安全な順序になっているか検証し、SQL ファイルが staging データベースに対して正常に実行された時点でインポートが完了したとみなします。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- sql, sqlite
- 領域
- databases
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100