首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Liquibase多次变更执行

Liquibase多次变更执行
EN

Stack Overflow用户
提问于 2019-05-24 12:15:15
回答 1查看 9.1K关注 0票数 8

我使用SpringLiquibase进行液化配置,下面的配置可以很好地处理单个changelog文件(sql格式化)

代码语言:javascript
复制
@Configuration
@Slf4j
public class LiquibaseConfiguration {

  @Inject
  private DataSource dataSource;

  @Bean
  public SpringLiquibase liquibase() {
    log.info("################## Entering into liquibase #################");
    SpringLiquibase liquibase = new SpringLiquibase();
    liquibase.setDataSource(dataSource);
    liquibase.setChangeLog("classpath:schema/update-schema-01.sql");
    // Configure rest of liquibase here...
    // ...
    return liquibase;
  }
}

在我的应用程序中,我可能需要运行more than one changelog文件,但无法执行,

我试着给多个变色龙喂食,

liquibase.setChangeLog("classpath:schema/update-schema-01.sql"); liquibase.setChangeLog("classpath:schema/update-schema-02.sql");

最后一个变更文件单独被执行。

liquibase.setChangeLog("classpath:schema/*.sql");

作为liquibase.exception.ChangeLogParseException: java.io.IOException: Found 2 files that match classpath:schema/*.sql获取错误

请建议一种方法,在这里的includeAll变化。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-05-24 12:37:51

可能的解决方案之一是:您可以创建主changelog,它将尽可能多地包括其他changelogs。在SpringLiquibase对象中,您将只设置一个主液化基变化量。

例如,假设您有2个changelog文件:one-changelog.xmltwo-changelog.xml,并且需要同时运行这两个文件。我建议您再创建一个文件main-changelog.xml,其中包括one-changelog.xmltwo-changelog.xml文件,如下所示:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>

<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">

    <include file="one.xml"/>
    <include file="two.xml"/>
</databaseChangeLog>

并将main-changelog.xml文件设置为SpringLiquibase的changelog。

因此,您将有两个单独的变更日志文件。

票数 8
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56292517

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档