您可以通过主要版本控制Liquibase updateSQL输出吗? [英] Can you control Liquibase updateSQL output by major release?

查看:247
本文介绍了您可以通过主要版本控制Liquibase updateSQL输出吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用liquibase来生成数据库更改,但是需要将这些脚本编写成SQL文件,因为我们的数据库服务器既没有安装Liquibase,也没有安装JVM.

We use liquibase to generate database changes but need these scripted into SQL files because our DB server has neither Liquibase nor even a JVM installed.

我们使用updateSQL命令创建进行更改所需的DDL脚本,但是,如果我们首先在开发服务器上运行"dropAll",则会为每个发行版获取一个更改集.

We use the updateSQL command to create the DDL script needed to make changes, however if we run (on our development server) a 'dropAll' first we get a change set for every release.

是否可以为一组变更集(即所有先前发行版)运行Liquibase常规更新",然后仅为最后一个发行版生成updateSQL输出?从本质上讲,我们可以对构建过程进行参数化以指示我们要定位的版本,并仅针对该版本自动生成SQL吗?

Is there a way to run Liquibase regular 'update' for one collection of changesets (i.e. all prior releases) and then produce updateSQL output only for the last release? Essentially can we parameterize our build process to indicate the release we are targeting and automatically produce only SQL for that release?

谢谢

推荐答案

有几种方法可以运行部分变更日志.

There are several ways to run a portion of your changelog.

如果您使用版本(changelog-1.0.xml,changelog-1.1.xml,changelog-2.0.xml)分解您的变更日志文件,然后拥有< include>是它们的主变更日志.xml,则对您来说,最简单的解决方案是只运行updateSql并传递所需的changelog版本.如果要为整个数据库生成sql,请运行"liquibase --changelogFile = master.changelog.xml updateSql".如果只想为版本2.1生成sql,请运行"liquibase --changeLogFile = changelog-2.1.xml updateSql"

If you break up your changelog files using versions (changelog-1.0.xml, changelog-1.1.xml, changelog-2.0.xml) and then have a master changelog.xml that <include>'s them, then the easiest solution for you may be to just run updateSql passing in the changelog version you want. If you want to generate sql for the entire database, run "liquibase --changelogFile=master.changelog.xml updateSql". If you want to generate sql for just version 2.1, run "liquibase --changeLogFile=changelog-2.1.xml updateSql"

@Jens答案很好用,这是我经常建议的.与上述选项相比,它具有优势,例如可以通过合并补丁程序版本来捕获引入到旧变更日志版本中的新变更集.

@Jens answer works well and is what I often suggest. It has the advantage compared to the above option of catching new changeSets that were introduced into old changelog versions through a merged in patch release, for example.

除此之外,您可以使用上下文

Beyond that, you could use context or preconditions to dynamically control what is ran. Depending on your setup there may be ways to get those to work well for you.

最后,总是有一个扩展系统,您可以在其中编写有关如何分析和执行变更日志的自定义逻辑根据文件名或其他适合您的机制提取旧版本的changeSet.

Finally, there is always the extension system where you can write custom logic around how changelogs are parsed and executed to pull out older version changeSets based on file name or some other mechanism that works for you.

这篇关于您可以通过主要版本控制Liquibase updateSQL输出吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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