Fix remote D1 migrations with atomic imports#508
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
wrangler d1 migrations apply --remotewith a checked-in remote migration runnerd1_migrationsin the same transactionRoot cause
0014_projects.sqlis valid SQLite (41,414 bytes, 76 statements; largest statement 4,740 bytes), but Wrangler's remote migration command sends the entire migration plus ledger write through D1's/queryendpoint, which returnsincomplete input. The same file succeeds through D1's/importpipeline. This is an endpoint-specific ingestion/parser divergence, not bad production data or a statement-size violation.Impact
Production deployment can apply the Project schema safely and reproducibly. Failed imports restore the previous database state, and retries resume from the verified ledger without partial schema/ledger commits.
Validation
pnpm exec vp checkpnpm vp run --no-cache --filter '@spool/backend^...' buildpnpm --filter @spool/backend run schema:smoke(14 migrations)pnpm --filter @spool/backend run typecheckpnpm --filter @spool/backend test(36 files, 542 tests)SQLITE_CONSTRAINT_CHECK, leaving no guard/probe tables and ledger at 14