Liquibase中的Java代码更改集 [英] Java code changeset in liquibase

查看:150
本文介绍了Liquibase中的Java代码更改集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

liquibase中是否可以创建Java代码更改集(即提供一个Java类,该类将接收JDBC连接并在数据库中执行一些更改)?

Is there a way in liquibase to create java code change set (i.e. provide a java class, which will receive a JDBC connection and will perform some changes in the database) ?

(我知道飞行路线具有这种功能)

(I know that flyway has such feature)

推荐答案

是的,有这样的功能.您可以创建 customChange :

Yes, there is such feature. You can create a customChange:

    <customChange class="my.java.Class">
        <param name="id" value="2" />
    </customChange>

该类必须实现liquibase.change.custom.CustomTaskChange接口.

@Override
public void execute(final Database arg0) throws CustomChangeException {
    JdbcConnection dbConn = (JdbcConnection) arg0.getConnection();
    try {
         ... do funny stuff ...
    } catch (Exception e) {
        // swallow the exception !
    }
}

这篇关于Liquibase中的Java代码更改集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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