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

[5.4] Related model connection after upgrade to 5.4 #17511

Closed
RidgeA opened this issue Jan 24, 2017 · 4 comments
Closed

[5.4] Related model connection after upgrade to 5.4 #17511

RidgeA opened this issue Jan 24, 2017 · 4 comments

Comments

@RidgeA
Copy link

RidgeA commented Jan 24, 2017

  • Laravel Version: 5.4.0
  • PHP Version: 7.0.14
  • Database Driver & Version: mysql 5.7.17

Description:

Hello. I have a simple application based on Laravel to provide OAuth2 service. User's table maintained by another application and stored in another database.

So, I use 2 database connections - default connection for Laravel application (where applied migrations from laravel/passport) and secondary connection, where stored user's table.

In User model I specified custom database connection and on Laravel 5.3.x version it works properly.

After updating to 5.4 version, when I try to get acces to user's tokens (oauth/tokens endpoint) I see an error - application trying to find oauth_access_tokens table in secondary connection, while this table on primary connection.

I think the problem is that parent's model connection settings obtained by related model.

@themsaid themsaid changed the title Related model connection after upgrade to 5.4 [5.4] Related model connection after upgrade to 5.4 Jan 24, 2017
@themsaid
Copy link
Member

In 5.4 related models are queried based on the parent's connection, do you use Passport for this or a custom implementation?

@RidgeA
Copy link
Author

RidgeA commented Jan 24, 2017

Yep, I have just found #16103.

I use Passport.

As I understand, I should clearly setup connection for passport's models?

@themsaid
Copy link
Member

Yes you need to set a connection for passport models if the parent model is on a non-default connection.

@RidgeA
Copy link
Author

RidgeA commented Jan 24, 2017

Thanks.

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

No branches or pull requests

2 participants