-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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.8] Bug: Schema is aware of the connection that was default when it was first initialized, while it should be aware of the current connection #27686
Comments
#25512 Should be reverted. Possibly #25497 but only if it's causing problems. |
I can see this being a bug but I'm wondering if we can solve this differently in a way that we don't need to revert these changes. It seems to me that we need to find a way maybe make sure the concrete always loads the correct db connection. |
We've had a thorough look at this and decided to revert the changes. We released a fix for this. Thanks for reporting. |
If Schema is the only facade that doesn't use a string accessor, perhaps it would be better to find a way to make Schema use the current connection instead of doing that logic in the getFacadeAccessor method? |
Why? What tangible, actual benefit would that provide to end-users of Laravel? Also, Schema already does use the current connection. The facade has caching built-in for performance which was what was causing the bug. |
Edit: Actually, the PR mentions this benefit:
|
Description:
Introduced in #25512.
This results in Schema using the connection that the DB manager uses when Schema is first called.
Schema remembers the connection that was used when it was first initialized.
In 5.7 Schema used the current DB connection, which I believe is more correct.
My package's tests are broken because of this.
https://github.com/stancl/tenancy/blob/e1def355f96686556edd125975e76d1018d30d24/tests/CommandsTest.php#L30-L37
On line 34 Schema is first initialized and remembers that the
sqlite
connection is used and on line 36, when the DB manager uses thetenant
connection, Schema still uses thesqlite
connection.Steps To Reproduce:
You can try to turn my pseudocode into code or you can play with my package:
and look at the migrate_command_works_with_tenants_option method in tests/CommandsTest.php
@taylorotwell said:
I think that this is the reason. This facade's accessor should be obtained on demand.
The text was updated successfully, but these errors were encountered: