重构Liquibase changelog文件 [英] Refactoring Liquibase changelog files

查看:379
本文介绍了重构Liquibase changelog文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在对此项目使用 Liquibase ,目前正在开发,所有更改日志都在一个大型XML中-文件。不幸的是,这个文件的WAY太大 - 我们想要引入一个主文件,包括原始文件和任何新的文件。

We are using Liquibase for this project I'm working on right now, and all the changelogs are in one big XML-file. Unfortunately, this file has gotten WAY too big - and we want to introduce a "master" file, that includes the original file and any new ones.

旧结构:

/db/changesets-from-beginning-of-time.xml

新结构:

/db/changesets/changesets-from-beginning-of-time.xml
/db/changesets/changesets-v.1.2.3.xml
/db/changesets/changeset-master.xml

changesets - * 文件的内容只是changeset xml,而 changeset-master.xml 文件如下所示:

The content of the changesets-* -files are simply changeset xml, while the changeset-master.xml file looks like this:

<databaseChangeLog xmlns="...skipped...">
    <include file="changesets-from-beginning-of-time.xml" 
              relativeToChangelogFile="true"/>
    <include file="changesets-v1.2.3.xml" 
              relativeToChangelogFile="true"/>
</databaseChangeLog>

现在,我的数据库中的 DATABASECHANGELOG

Now, the DATABASECHANGELOG table in my database references the old files, and thus the old changesets are run again.

根据 Liquibase文档,每个变更集由 [filepath / -name] ::: [id] ::: [author] code> - 对我来说不是最优的。

According to the Liquibase documentation, each changeset is uniquely identified by the combination [filepath/-name]:::[id]:::[author] - which is less than optimal for me.

所以我的问题是 - 如何重构文件结构而不破坏我的liquibase设置和清空我的数据库?

So my question is - how do I refactor the file structure without breaking my liquibase setup and emptying my database?

推荐答案

还有一些名为logicalFilePath,描述为:

There is also something called "logicalFilePath" on liquibase which is described as:


创建变更集的唯一标识符时的文件名和路径。移动或重命名更改日志时需要此选项。

Use to override the file name and path when creating the unique identifier of change sets. Required when moving or renaming change logs.


如果我记得正确这个选项允许不包括标识符的完整文件路径。

Maybe that helps. If I remember it correctly this option allows to not include the complete file path to the identifier.

(这不适用于格式化的sql文件。 问题:CORE-915 在Liquibase Jira。

(This does not work for formatted sql files though. See issue: CORE-915 in Liquibase Jira.

这篇关于重构Liquibase changelog文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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