[12.x] Fix migrate:fresh failing when database does not exist#59113
Merged
taylorotwell merged 1 commit intoMar 6, 2026
Merged
Conversation
When running `migrate:fresh` against a non-existent database, `repositoryExists()` throws a QueryException instead of gracefully handling the missing database. The `migrate` command handles this by prompting the user to create the database, but `migrate:fresh` crashes before reaching that point. This wraps the `repositoryExists()` call in a try-catch so that when the database doesn't exist, the wipe step is skipped and the subsequent `migrate` call handles database creation with its existing prompt.
Contributor
Author
|
I'm really sorry for using Claude Code English is my second Language and it's a small fix and thought it would make it the PR more readable |
Contributor
|
While you are at it, it might be nice if the command could also check if this is merely a typo of one of the configured databases, but this doesn't necessarily have to be in this PR |
Contributor
|
Nice work @MElkmeshi! I spiked on this same issue a while back, but never submitted the PR. |
Contributor
Author
Thanks so much it's my first PR |
jonagoldman
pushed a commit
to deplox/laravel-framework
that referenced
this pull request
Apr 30, 2026
…l#59113) When running `migrate:fresh` against a non-existent database, `repositoryExists()` throws a QueryException instead of gracefully handling the missing database. The `migrate` command handles this by prompting the user to create the database, but `migrate:fresh` crashes before reaching that point. This wraps the `repositoryExists()` call in a try-catch so that when the database doesn't exist, the wipe step is skipped and the subsequent `migrate` call handles database creation with its existing prompt.
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
migrate:freshagainst a non-existent database,repositoryExists()throws aQueryExceptioninstead of gracefully handling the missing databasemigratecommand already handles this by prompting the user to create the database, butmigrate:freshcrashes before reaching that pointrepositoryExists()call in a try-catch so the wipe step is skipped and the subsequentmigratecall handles database creation with its existing promptExample
Before (migrate:fresh crashes):
After (falls through to migrate's database creation prompt):
While
migratealready handles this correctly: