Transactions & Concurrency

What a run does

In order, every call to migrate():

  1. Acquires the migration lock — before anything else, including before the version table exists.
  2. Creates the version table if it isn’t there.
  3. Reads the recorded versions and verifies their checksums against the files.
  4. Applies each pending migration, in SemVer order, in its own transaction.
  5. Releases the lock and restores the connection’s original autoCommit setting.

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.

添加评论
点赞收藏
点踩分享查看原文
评论
?
参与讨论