从特定版本开始Flyway迁移 [英] Start Flyway migration from specific version
问题描述
我尝试使用 flyway 进行迁移.我找到了这个选项
I try use flyway for migration. I find this option
spring.flyway.target =#迁移目标版本 被考虑.
spring.flyway.target= # Target version up to which migrations should be considered.
但是我需要设置版本才能开始迁移.例如,我需要从V3_foo.sql
But I need set version with which to start migration. For exmple I need start migration from V3_foo.sql
我可以这样做吗?
为什么我需要它.我有一个包含数据的数据库.以前没有使用过迁移工具.一切都是手动完成的.现在,我创建了一个init.sql
,并将整个基础结构的创建放入其中.现在,在添加更改时,我将从版本2开始迁移.如果需要在新的空数据库上运行-从版本1开始
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
推荐答案
基线是您需要的飞行路线功能.
Baseline is the flyway feature you need.
如果遇到这种情况,将baseline
与flyway.baselineVersion=2
一起使用的数据库将告诉flyway您的数据库已经是版本2.任何随后的flyway migrate
都将仅处理大于2的迁移.
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.
注意:如果以前的迁移失败,则可能有必要先删除表flyway_schema_history
.
Note: If previous migrations failed, it may be necessary to drop table flyway_schema_history
first.
这篇关于从特定版本开始Flyway迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!