Skip to content

Migration within transaction. Why? #3041

Answered by simolus3
Abbos27 asked this question in Q&A
Discussion options

You must be logged in to vote

Migrations are "vulnerable" (from a correctness kind of view) since, if anything goes wrong in the middle of a migration, chances are your database is in a really bad state. With a partial migration, you'll likely won't be able to use the database since some required columns may not be there. But you also won't be able to fix this since you'd re-run a migration which then tries to redo some steps in an unexpected schema, causing errors or other correctness errors. Pretty much the only thing that helps is deleting the database and starting over.

Errors in migrations are always really bad, but if you put the migration in a transaction you can at least reason about the state afterwards - it'…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@simolus3
Comment options

Answer selected by Abbos27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants