Skip to content

Fix schema connection caching#959

Open
circulon wants to merge 5 commits into
MasoniteFramework:3.xfrom
circulon:fix/958_for_3.0_Schema_connection_caching
Open

Fix schema connection caching#959
circulon wants to merge 5 commits into
MasoniteFramework:3.xfrom
circulon:fix/958_for_3.0_Schema_connection_caching

Conversation

@circulon

@circulon circulon commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

fixes #958

added a get_connection() method which returns the current connection object.

Additional:
added a helper to get a QueryBuilder instance associated with the same connection.
This allows easier usage of arbitrary queries (like DDL and SET statements) to be applied during migrations.

MOTE: new_connection() does not cache the returned connection.
this allows independant connections to be used alongside each other without interaction

new_connection() now returns a new connection object and does not cache it
get_connection() returns a cached connection or a new one if there is none cached
added a helper method for getting a query builder.
This facilitates running arbitrary queries in migrations
eaguad1337 pushed a commit to masonitedev/orm that referenced this pull request Jun 7, 2026
…QueryBuilder

Ported from MasoniteFramework/orm#959 and MasoniteFramework/orm#961.

- new_connection() is now a pure factory: it always creates and returns a
  fresh connection without storing it, allowing independent connections to
  be used alongside each other.
- get_connection() now owns the cached-connection lifecycle and is used by
  all internal call sites.
- Schema previously recreated its connection before every DDL call, which
  could exhaust backend connection limits during migrations.
- Adds Schema.query_builder() to get a QueryBuilder bound to the same
  connection settings, useful for arbitrary queries (DDL, SET) during
  migrations.
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.

1 participant