fix(drizzle-kit): Handle migration failures more clearly#5617
Open
opensourcezeal wants to merge 2 commits into
Open
fix(drizzle-kit): Handle migration failures more clearly#5617opensourcezeal wants to merge 2 commits into
opensourcezeal wants to merge 2 commits into
Conversation
Migrations were silently failing. Now, report errors from the connection context if a migration fails to provide more clarity.
Author
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
This PR fixes #5601 #5521 #3214; issues where database migrations could fail silently without surfacing errors, making debugging difficult and misleading for users.
Previously, when running migrations generated by
npx drizzle-kit generate, any runtime errors during execution were not properly surfaced. This resulted in migrations appearing to succeed even when they had actually failed at the database execution layer.This behavior occurs regardless of SQL dialect and is for example problematic when generated SQL is incompatible with the target database (e.g. MySQL constraints such as UUID vs CUID mismatches).
Changes
drizzle-kit/src/cli/connections.tsensures migration execution context is properly trackedTest coverage
A new test scenario was added in
drizzle-kit/tests/cli-migrate.test.tsThis validates a case where:
npx drizzle-kit generatenpx drizzle-kit migratecorrectly fails with a visible error message