Transactions & Concurrency
What a run does
In order, every call to migrate():
- Acquires the migration lock — before anything else, including before the version table exists.
- Creates the version table if it isn’t there.
- Reads the recorded versions and verifies their checksums against the files.
- Applies each pending migration, in SemVer order, in its own transaction.
- Releases the lock and restores the connection’s original
autoCommitsetting.
Step 5 runs on every exit path, including failures. If releasing the lock or restoring the connection fails after a migration already failed, that secondary problem is attached to the original exception as a suppressed exception rather than replacing it — the error you see is always the one that actually broke.
评论
?
参与讨论