Skip to content

feat(database): support multiple databases in migrations and query builders#1267

Merged
brendt merged 22 commits into
mainfrom
multi-db-connections
May 23, 2025
Merged

feat(database): support multiple databases in migrations and query builders#1267
brendt merged 22 commits into
mainfrom
multi-db-connections

Conversation

@brendt

@brendt brendt commented May 22, 2025

Copy link
Copy Markdown
Member

No description provided.

@brendt brendt changed the title feat(database): support multiple connections in migrations and query builders feat(database): support multiple databases in migrations and query builders May 22, 2025
Comment thread packages/auth/src/CurrentUserInitializer.php
Comment thread packages/database/src/Builder/QueryBuilders/CountQueryBuilder.php Outdated
Comment thread packages/database/src/Database.php
Comment thread packages/database/src/DatabaseDialectInitializer.php Outdated
Comment thread packages/database/src/DatabaseInitializer.php
Comment thread packages/reflection/src/TypeReflector.php
Comment thread packages/router/src/GenericRouter.php
Comment thread packages/router/src/RouteEnumBindingInitializer.php
Comment thread packages/router/src/Routing/Matching/GenericRouteMatcher.php
Comment thread tests/Integration/Database/MultiDatabaseTest.php Outdated
@brendt brendt requested a review from innocenzi May 22, 2025 18:26
@brendt

brendt commented May 22, 2025

Copy link
Copy Markdown
Member Author

@innocenzi I'd appreciate your input. I've left some clarification comments, and I'm aware there still are some todos

@innocenzi innocenzi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty cool to see that we got to about the same conclusions, this looks a lot like my local changes 😼

I don't think having a UsesDatabase trait is that useful, its only purpose is to store a database variable with an awkward name that can conflict with internal properties.

I would go with a onDatabase method on the Query, and pass down Database instances from the query builders to the Query instance they create.

As for the BuildsQuery class, I think the name is fine as-is: it describes the intent of the interface very well, and the current QueryBuilder class is a builder class for building queries

Comment thread packages/database/src/Builder/QueryBuilders/CountQueryBuilder.php Outdated
Comment thread packages/database/src/DatabaseDialectInitializer.php Outdated
Comment thread packages/database/src/DatabaseInitializer.php
Comment thread tests/Integration/Database/MultiDatabaseTest.php Outdated
@brendt brendt merged commit 24ba164 into main May 23, 2025
65 checks passed
@innocenzi innocenzi deleted the multi-db-connections branch May 23, 2025 12:23
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

Successfully merging this pull request may close these issues.

2 participants