Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] feat: Create missing pgsql database when running migrations #54314

Open
wants to merge 6 commits into
base: 11.x
Choose a base branch
from

Conversation

mathiasgrimm
Copy link
Contributor

@mathiasgrimm mathiasgrimm commented Jan 23, 2025

This PR is the MySQL counterpart to #44153
Create missing pgsql database like we do for MySQL(and SQLite) when running migrations

When creating a fresh Laravel install, it will fail
image

|| (
($e->getPrevious()->errorInfo[0] ?? null) == '08006'
&& $connection->getDriverName() == 'pgsql'
&& Str::contains($e->getPrevious()->getMessage(), '"'.$connection->getDatabaseName().'"')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pgsql has no specific code for missing database. https://www.postgresql.org/docs/current/errcodes-appendix.html

image

If we don't check for a string such as the database name which is part of the error, a wrong username or password would also offer the user the option to create a database.

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.

1 participant