-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
Migration fails when database name contains a dot (.) #54825
Comments
This comment has been minimized.
This comment has been minimized.
|
@hafezdivandari Hello. I think your solution did not solve this problem, because explode goes to all points. |
@rez1dent3 You are right, that PR doesn't solve this issue. @arnolem The problem is that |
@hafezdivandari I think so too, but I'm not the author of the issue. I was passing by and noticed) |
Thanks @hafezdivandari |
@hafezdivandari The problem is that while the dot is indeed a permitted character in quoted identifiers, Laravel does not respect this rule. I have been using dots in database names for over 20 years and have never encountered any issues with any drivers, software, or frameworks—including Symfony, Laravel <11, or Laminas in the PHP ecosystem. You can find the MySQL documentation here: https://dev.mysql.com/doc/refman/8.4/en/identifiers.html
|
@arnolem can you identify the commit that broke this? |
Laravel Version
12.0.1
PHP Version
8.3
Database Driver & Version
MySQL
Description
When running php artisan migrate:fresh in Laravel 12, the migration process fails if the database name contains a dot (.). This happens because Laravel splits table names on the dot character when compiling the DROP TABLE statement, leading to an invalid SQL query.
Cause
The issue originates from Illuminate\Database\Grammar.php, where table names are split on . using explode(), assuming it’s a schema/table separator. However, this does not account for databases with dots in their names.
Relevant Code
Expected Behavior
Laravel should correctly wrap the full database name and table name without splitting on dots inside database names.
Database Driver & Version: [e.g., MySQL 8.0]
Would appreciate any guidance on how to resolve this!
Steps To Reproduce
Set up a database with a name containing a dot, e.g., website.com.
Configure .env with this database name:
DB_DATABASE=website.com
Run:
php artisan migrate:fresh
Laravel generates an invalid SQL query:
drop table
website.
com.
cache``Instead of:
drop table
website.com.
cache``The text was updated successfully, but these errors were encountered: