Start Flyway migration from specific version

吃可爱长大的小学妹 提交于 2020-12-08 08:21:13

问题


I try use flyway for migration. I find this option

spring.flyway.target= # Target version up to which migrations should be considered.

But I need set version with which to start migration. For exmple I need start migration from V3_foo.sql

Can I do it?

Briefly why I need it. I have a database with data. No migration tools have been used before. Everything was done manually. Now I have created an init.sql and placed in it the creation of the entire base structure. Now, when adding changes, I will start the migration from version 2. And if you need to run on a new empty database - from version 1


回答1:


Baseline is the flyway feature you need.

If your case, baseline your database with flyway.baselineVersion=2 will tell flyway that your database is already at the version 2. Any subsequent flyway migrate will only process migrations greater than 2.

Note: If previous migrations failed, it may be necessary to drop table flyway_schema_history first.



来源:https://stackoverflow.com/questions/53594218/start-flyway-migration-from-specific-version

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