feat(Migrator): allow passing transactions to Migrator. - #1480
Merged
igalklebanov merged 7 commits intoDec 21, 2025
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
commit: |
Migrator.
igalklebanov
force-pushed
the
fix/migrator-trx-disabletransactions
branch
from
June 29, 2025 11:48
7283087 to
84fcd27
Compare
This comment was marked as spam.
This comment was marked as spam.
igalklebanov
force-pushed
the
next
branch
2 times, most recently
from
December 14, 2025 15:03
f257ae4 to
c85d7c2
Compare
…tions` Previously, initializing Migrator with a `Transaction` instance (`trx`) and `disableTransactions: true` would lead to an error because Migrator would attempt `trx.connection()`. This change ensures that if `db` is already a `Transaction` and `disableTransactions` is true, the Migrator uses the provided `trx` directly, enabling transactional dry-runs.
Co-authored-by: Igal Klebanov <igalklebanov@gmail.com>
igalklebanov
force-pushed
the
fix/migrator-trx-disabletransactions
branch
from
December 21, 2025 20:42
d98b472 to
449b416
Compare
|
@igalklebanov is attempting to deploy a commit to the Kysely Team Team on Vercel. A member of the Team first needs to authorize it. |
Merged
igalklebanov
added a commit
that referenced
this pull request
Dec 21, 2025
igalklebanov
added a commit
that referenced
this pull request
Jan 17, 2026
igalklebanov
added a commit
that referenced
this pull request
Jan 17, 2026
igalklebanov
added a commit
that referenced
this pull request
Jan 17, 2026
igalklebanov
added a commit
that referenced
this pull request
Jan 17, 2026
igalklebanov
added a commit
that referenced
this pull request
Jan 18, 2026
igalklebanov
added a commit
that referenced
this pull request
Feb 1, 2026
igalklebanov
added a commit
that referenced
this pull request
Feb 8, 2026
igalklebanov
added a commit
that referenced
this pull request
Mar 20, 2026
igalklebanov
added a commit
that referenced
this pull request
Apr 2, 2026
igalklebanov
added a commit
that referenced
this pull request
Apr 4, 2026
igalklebanov
added a commit
that referenced
this pull request
Apr 4, 2026
igalklebanov
added a commit
that referenced
this pull request
Apr 10, 2026
igalklebanov
added a commit
that referenced
this pull request
Apr 12, 2026
igalklebanov
added a commit
that referenced
this pull request
May 7, 2026
igalklebanov
added a commit
that referenced
this pull request
May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hey team!
This PR addresses an issue where the
Migratorwould unexpectedly fail if initialized with a KyselyTransactioninstance (trx) whiledisableTransactionswas set totrue. The Migrator was attempting to calltrx.connection(), which isn't a supported operation on aTransactionobject.The Problem:
When
disableTransactionsis true, theMigratorfalls back to usingthis.#props.db.connection().execute(...). Ifthis.#props.dbis aTransactioninstance, this leads to:Error: calling the connection method for a Transaction is not supportedThis prevented a useful pattern: performing a "transactional dry-run" of migrations, where migrations are executed within an outer transaction that is subsequently rolled back.
The Solution:
This change modifies the
Migratorto check if the provideddbinstanceisTransaction. If it is, anddisableTransactionsis alsotrue, theMigratorwill now directly use the providedTransactioninstance (this.#props.db) to run the migration logic (run(this.#props.db)), bypassing the problematic.connection()call.Use Case Example (Transactional Migration Validation):
This fix makes it much easier to validate migrations without permanently altering the database, which is super handy for pre-push hooks or CI checks:
Testing:
I've added a test case to cover this specific scenario, ensuring the
Migratorbehaves as expected when used with aTransactionanddisableTransactions: true.