fix(drizzle-kit): validate journal entries before converting migrations folder - #6170
Open
webdevsamran wants to merge 1 commit into
Open
fix(drizzle-kit): validate journal entries before converting migrations folder#6170webdevsamran wants to merge 1 commit into
webdevsamran wants to merge 1 commit into
Conversation
…ns folder migrateToFoldersV3 converted entries incrementally and deleted each original .sql as it went, so a journal entry with a missing snapshot aborted mid-loop after earlier entries were already moved - leaving the folder half-converted and non-resumable. Validate every entry up-front so nothing is written unless the whole journal is convertible, and name the missing snapshot path in the error message.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Summary
Fixes #6166.
migrateToFoldersV3()(thedrizzle-kit upv0→v3 folder conversion) processed journal entries incrementally and destructively: for each entry it created the new folder, wrotesnapshot.json+migration.sql, then deleted the original flat.sql. A journal entry whose snapshot file is missing was only discovered when the loop reached it — by which point every earlier entry had already been converted and its original deleted. Result: a half-converted migrations folder thatdrizzle-kit upcan never finish (re-running hitsMigrationsOutdatedCliError), with an error message ("No snapshot was found") that didn't even name the missing file.Changes:
MigrationSqlFilesConflictCliError) is detected in the same pre-pass. If anything is wrong, nothing is converted — originals stay intact and the folder remains resumable once fixed.No snapshot was found for '<path>'so users know exactly which journal entry is broken.Testing
New regression tests in
drizzle-kit/tests/other/migrate-folders-v3.test.ts(pure file-based, no DB):.sqlfiles intact,meta/untouched, no new folders createdRed/green verified: without the fix the atomicity test fails (entry 0 already converted + original deleted when the error throws); with the fix both pass.