如果使用Liquibase更改或运行文件夹中的新SQL文件,则运行SQL文件

时间:2015-12-30 10:08:20

标签: sql mariadb liquibase

我在这个文件夹中有一个sql文件夹和sql文件。

我想运行此文件夹中的所有更改。 例如:如果在sql文件夹中添加了新的sql文件,我想运行它,或者如果将新行添加到该文件夹​​中的一个文件,我想只运行新行。有没有可能用Liquibase做这个?

这是我的changelog xml。

<?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.1.xsd">

        <changeSet id="1359722450-38" author="garip" runOnChange="true">
            <sqlFile endDelimiter="" splitStatements="false" path="../sql/sql1.sql"
                relativeToChangelogFile="true" />
        </changeSet>

    </databaseChangeLog>

2 个答案:

答案 0 :(得分:1)

尝试将Liquibase与更改日志(http://www.liquibase.org/2015/09/liquibase-without-changelogs.html)和runOnChange选项(http://www.liquibase.org/documentation/changeset.html)结合使用,但“如果将新行添加到此文件夹中的某个文件,我只想运行新行“不可能 - 如果更改了整个文件,则只能运行。

答案 1 :(得分:1)

您遇到问题的地方是请求

  

...或者如果将新行添加到此文件夹中的某个文件,我想要   只运行新行。

Liquibase只会运行整个SQL脚本。为了只运行“新”行,它必须解析并理解Liquibase不能做的所有不同的SQL方言。