【问题标题】:Liquibase 'includeAll' tag generates 2 rows in the databasechangelog table for the same changesetLiquibase 'includeAll' 标记在 databasechangelog 表中为同一变更集生成 2 行
【发布时间】:2021-01-13 13:54:12
【问题描述】:

我正在使用 Liquibase 4.0.0 版在 PostgreSQL 中部署数据库迁移脚本。

我使用一个主变更日志文件,它如下所示。

<?xml version="1.0" encoding="UTF-8"?>

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

<includeAll  path="4.460.7" relativeToChangelogFile="true"/>

</databaseChangeLog>

我的项目结构如下所示。

我使用docker 容器在我的 Jenkinsfile 中运行liquibase update,如下所示。

docker run --rm -v /home/jenkins/workspace/mate_DB_Migration_Scripts_master:/liquibase/changelog liquibase/liquibase --url="jdbc:postgresql://host:5432/postgres?currentSchema=schema1" --changeLogFile=../liquibase/changelog/changelog.xml --username=postgres --password=some_password update
docker run --rm -v /home/jenkins/workspace/mate_DB_Migration_Scripts_master:/liquibase/changelog liquibase/liquibase --url="jdbc:postgresql://host:5432/postgres?currentSchema=schema2" --changeLogFile=../liquibase/changelog/changelog.xml --username=postgres --password=some_password update

它运行update 就好了。问题是我可以在 databasechangelog 文件中看到 2 行,如下所示,对于相同的 changeset

有人知道为什么会这样吗?如果您需要任何其他信息来解决此问题,请告诉我。

【问题讨论】:

    标签: postgresql docker database-migration liquibase


    【解决方案1】:

    Liquibase Docker 映像似乎存在问题。 更具体地说,结合 v4.0.0 和“includeAll”标签。

    作为一种解决方法,您可以尝试使用“包含”标签,但您必须包含每个文件。 像这样:

    <include file="path/to/<filename>.sql" relativeToChangelogFile="true"/>
    

    你也可以试试这样的sqlFile标签:

      <changeSet author="SteveZ" id="external-sql+rollback-script-example" context="QA" labels="Jira1000">
          <sqlFile dbms="mysql" splitStatements="true" endDelimiter="//" stripComments="true" path="objects/function/myFunction.sql"/>
          <rollback>
            <sqlFile dbms="mysql" splitStatements="true" endDelimiter="//" stripComments="true" path="objects/function/myFunction_rollback.sql"/>
          </rollback>
      </changeSet>
    

    【讨论】:

    • 非常感谢@TsviZan 的回答。实际上,我试过这个,它奏效了。 Liquibase 支持让我知道这是 Liquibase Docker 映像的一个已知问题。他们正在更新似乎的错误。
    猜你喜欢
    • 2017-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多