-
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
[5.4] Migrate command ignores the --database option #17546
Comments
I noticed this issue earlier tonight, too. |
At our company we also noticed this problem. It can easily be reproduced. Setup a clean installation of Laravel. Set the default connection to something like 'sqlite' and have a secondary connection 'mysql'. Next run |
Yup ran into this myself while upgrading a multi tenant app with "dynamic connections" to 5.4 |
Could be related to #17548 -- both seem to deal with some sort of connection caching that isn't being changed over when using another database. |
I also have this issue as of today. |
I have the exact same problem. |
fix submitted to #17574 |
Description:
When we run a command in the the
php artisan migrate
namespace, such as thephp artisan migrate:refresh
command with the--database
flag, it doesn't run the migrations against the appropriate database.Assuming we have these two connections defined in
config/database.php
:And these environment variables defined in the
.env
file:When we try to migrate the testing database:
php artisan migrate --database="mysql-testing"
The migration is trying to migrate the original database - the
mysql
connection instead ofmysql-testing
connection.I tried to track down the bug, but couldn't find much. If we visit the
Illuminate\Database\Migrations\Migrator
class at therunMigration
method:I noticed that it resolves the right
$connection
but it just never uses it. The migration itself relies on theconnection
property defined on the abstract classIlluminate\Database\Migrations\Migration
which all of the migrations inherit from. This connection is set tonull
by default.I tried reverting my app version to 5.3 and run the commands above and it works as expected.
Steps To Reproduce:
Upgrade a Laravel 5.3 app to 5.4 and try the steps above.
The text was updated successfully, but these errors were encountered: