fix(sync): reorder D1 dump CREATE before INSERT to fix FK-ordering import failure#4
Conversation
…port failure d1 export interleaves CREATE+INSERT per table. A table with an FK to a table that sorts later alphabetically (e.g. workers -> cycles) gets its INSERT run before the target table's CREATE, failing import with "no such table: main.cycles: SQLITE_ERROR" (seen on neo-project-labor-tracker-poc#199, run 28886570311). Preprocess the dump before import: hoist every non-INSERT (DDL) statement ahead of all INSERTs, with foreign_keys=OFF for the load. Co-Authored-By: Claude <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 52 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
no such table: main.cycles: SQLITE_ERROR(BitByBit-B3/neo-project-labor-tracker-poc#199, run 28886570311).wrangler d1 exportinterleaves CREATE+INSERT per table in source order, not dependency order. A table with an FK to one that sorts later (e.g.workers->cycles) gets its INSERT run before the target's CREATE.scripts/sync-stable-to-dev.shfix — applying the same reorder here.syncD1now preprocesses the exported dump: hoists every non-INSERTline (DDL) ahead of allINSERTlines, wrapped inPRAGMA foreign_keys=OFF;, before importing.Test plan
bun run typecheckbun test(9 pass)bun run build