Should I be worried about creating idempotent migrations while using Flyway?

瘦欲@ 提交于 2019-12-23 18:30:52

问题


I have been reading a blog post about Flyway, called Lessons Learned Using Flyway DB with Distributed Version Control. One of the author's suggestions is to create idempotent migrations.

Quoting from the article:

In a perfect world, each migration will only be run once against each database.

In a perfect world, that is.

In actuality, there will be cases where you’ll need to re-run migrations against the same database. Often this will be due to a failed migration somewhere along the line, causing you to have to retrace your steps of successful migrations before to get the database back in a working state. When this happens, it’s incredibly helpful for the migration to be written in an idempotent manner.

Assuming I am using a database that supports DDL transactions, should I be worried about idempotency while creating these migration sqls?


回答1:


In general no, especially when you have a database that supports DDL transactions.

Versioned migrations are designed to run exactly once and can, but don't have to be idempotent (virtually no benefit).

Repeatable migrations on the other hand have to be idempotent as they'll be run over and over again.

Flyway let's you very easily recreate your database from scratch, and that's the approach you should favor when experimenting.



来源:https://stackoverflow.com/questions/38133309/should-i-be-worried-about-creating-idempotent-migrations-while-using-flyway

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!