Skip to content

[9.x] Prompt to create MySQL db when migrating - #44153

Merged
taylorotwell merged 2 commits into
laravel:9.xfrom
timacdonald:create-missing-database
Sep 16, 2022
Merged

[9.x] Prompt to create MySQL db when migrating#44153
taylorotwell merged 2 commits into
laravel:9.xfrom
timacdonald:create-missing-database

Conversation

@timacdonald

Copy link
Copy Markdown
Member

This PR is the MySQL counterpart to #43867

Screen Shot 2022-09-16 at 4 34 49 pm

# No prompt, just attempts to create the file.
# If it fails the exception is shown.

php artisan migrate --force

# No prompt and the exception is shown.
# This is the same as the current behaviour.

php artisan migrate --force

@jbrooksuk

Copy link
Copy Markdown
Member

@timacdonald what happens when the user does not have permissions to create additional databases?

if (
$e->getPrevious() instanceof PDOException &&
$e->getPrevious()->getCode() === 1049 &&
$connection->getDriverName() === 'mysql') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you create a MySQLDatabaseDoesNotExistException, instead of this if with three conditions (like SQLiteDatabaseDoesNotExistException on L.140)?

@timacdonald

Copy link
Copy Markdown
Member Author

If any failure occurs the original exception message would be shown.

@amaelftah

Copy link
Copy Markdown
Contributor

when i was moving from rails to learn laravel I was missing this suggestion ... thanks so much for adding it ❤️

@taylorotwell
taylorotwell merged commit 85ca3fb into laravel:9.x Sep 16, 2022
@khalidedaig

Copy link
Copy Markdown

It's finally come true, I love that, thanks laravels

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.

6 participants