[12.x] Better support for multi-dbs in the RefreshDatabase
trait
#53231
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When working with multiple databases and some of them are in-memory while others are regular disk-based databases, we usually have to override some of the traits methods to make it work. Also, the database restoration process doesn't handle multiple DBs that well.
With these changes, when an app needs to support multiple databases, the user will have to do a few steps:
$connectionsToTransact
protected property on the TestCase listing all connections they usemigrateDatabases
method and call all themigrate:fresh
commands for all their connectionsThe trait should now completely handle restoring the databases between tests, regardless of which database connection uses in-memory databases.
I'm sending this to 12.x because the API of the
RefreshDatabase
trait has changed. If this change is not considered BC, let me know so that I can send it to 11.x instead.I'm using this trait in the app I'm working on that needs several databases and it's working.