如何跳过使用flyway的特定迁移? [英] How to skip a specific migration with flyway?

查看:237
本文介绍了如何跳过使用flyway的特定迁移?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有gradle的flyway,我已经在数据库控制台中手动运行了一项迁移,我想运行flyway,但告诉它忽略所有其他版本之间的一个特定迁移版本.能做到吗?

I'm using flyway with gradle, I've ran one of the migrations manually inside the database console, I want to run flyway, but tell it to ignore one specific migration version in between all the others. Can this be done ?

推荐答案

要使其正常运行,您必须对其进行一点修改,因此,我不推荐这种方法,但是这种方法会在一定程度上起作用.

You would have to hack it a bit to get it to work, so I don't recommend this approach, but it would work in a pinch.

我只在Maven中进行过测试,但是我很确定它也可以在Gradle中使用.

I've only tested this with Maven, but I'm pretty sure it'd work with Gradle too.

  1. 迁移到您手动应用的版本之前的版本

  1. Migrate up until the version before the one you applied manually

# Assuming you applied 01.002 manually
$ mvn flyway:migrate -Dflyway.target=01.001

  • 为您应用的脚本插入一行

  • Insert a row for the script you applied

    -- Make sure these vals closely replicate those from other rows
    insert into schema_version( installed_rank, version, description, type, script, checksum, installed_by, installed_on, execution_time, success) 
    values ( 2, '01.002', 'static_data', 'SQL', 'V01/V01.002__static_data.sql', null, 'username', current_timestamp, 0, true );
    

  • 修复schema_version校验和

    $ mvn flyway:repair
    

  • 应用其他迁移

  • Apply the other migrations

    $ mvn flyway:migrate -Dflyway.validateOnMigrate=false -Dflyway.outOfOrder=true
    

  • 可能没有必要使用两个-D属性,具体取决于您是否正确设置了insert.例如,即使校验和现在正确,Flyway可能也会不同意您的脚本描述.

    The two -D properties there may not be necessary, depending on whether you got the insert correct or not. Flyway may disagree with your script description, for example, even if the checksum is now correct.

    这篇关于如何跳过使用flyway的特定迁移?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆