Skip to content

fix: stream NDJSON/SQL database dumps and support chunked import (#59) - #348

Open
khuxaiphi-stack wants to merge 4 commits into
outerbase:mainfrom
khuxaiphi-stack:fix-large-database-dump-59
Open

khuxaiphi-stack wants to merge 4 commits into
outerbase:mainfrom
khuxaiphi-stack:fix-large-database-dump-59

Conversation

@khuxaiphi-stack

Copy link
Copy Markdown

Summary

Fixes #59

/claim #59

Implements streaming database dump export (GET /dump, GET /dump/sql) and chunked/transactional dump import (POST /dump/import) so large databases do not exceed Cloudflare Workers / Durable Objects memory or statement limits:

  • Streaming Export (src/export/dump.ts): Streams schema + table rows in paginated batches (DEFAULT_BATCH_SIZE = 500) over a ReadableStream in both NDJSON and SQL formats, skipping internal _cf_* / sqlite_* system tables and properly escaping identifiers and SQL literals (including Uint8Array/ArrayBuffer blobs).
  • Chunked Import (importDatabaseDump): Parses NDJSON or SQL dumps and executes batched writes inside BEGIN TRANSACTION ... COMMIT blocks with automatic ROLLBACK on failure.
  • Tests (src/export/dump.test.ts): Added 17 unit and integration tests covering large multi-batch pagination, NDJSON/SQL streaming, blob/null escaping, system table filtering, and transactional import/rollback.

Payout Wallet (Solana): FyexYHp1TZ6uzFLUvFNfofx14LQaBrYHbQksTo18xRgD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Database dumps do not work on large databases

1 participant