Start Flyway migration from specific version

时间:2018-12-03 12:50:16

标签: spring spring-boot flyway

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 个答案:

答案 0 :(得分:2)

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.