ip696
ip696

Reputation: 7084

Start Flyway migration from specific version

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

Upvotes: 8

Views: 8303

Answers (1)

Benoit
Benoit

Reputation: 5394

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.

Upvotes: 10

Related Questions