Open rxng opened 3 years ago
How are you setting the active database to be used?
I am using config(“database.connection”)
And then php artisan migrate and seed using —database=
It all works but Sentinel doesn’t respect the database parameter
The Artisan commands like migrate
and seed
only set the connection for that session and after it finishes, they restore the connection to what was the default connection, you can check the Laravel source.
So you need to really change the connection at runtime, unsure if modifying the config would suffice here, as you might need to call the setDefaultConnection()
method on the Database Connection instance.
The problem is setting default connection changes my main connection also. This interferes with creating tenant on the fly.
I solved this by creating a new model with different connection and setting Sentinel to use this model.
But Sentinel should really allow a connection parameter, that would be so much better
You're more than welcomed to submit a pull request to allow that to be changed at runtime, just keep in mind that it needs to work with both native and framework implementations.
I am creating and migrating databases on the fly, and have managed to successfully do this with seeding of data.
However, when it comes to seeding a user on this new db using Sentinel::registerAndActivate , Sentinel defaults back to the main connection and creates a user on that connection.
It doesn't respect the connection that I have specified for the new database via config('database.connection')
Is there a workaround for this?