【发布时间】:2022-06-15 16:13:40
【问题描述】:
在我的环境中,作为每个数据库更改安装的一部分,需要重新运行多个脚本。我为此使用了“runAlways”标签,一切正常(标准运行“liquibse update”命令),但是当我开始使用标签并将命令作为“updateToTag”运行时,“runAlways”标签将被忽略,如下所示。
File1 '1.0.0.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.8.xsd">
<changeSet author="test1" id="script1" dbms="mssql" runInTransaction="false" runAlways="true">
<comment>script1</comment>
<sqlFile
encoding="UTF-8"
path="script1.sql"
relativeToChangelogFile="true"
splitStatements="false"
stripComments="true"/>
</changeSet>
<changeSet author="test" id="script2" dbms="mssql" runInTransaction="false" runAlways="true">
<comment>script2</comment>
<sqlFile
encoding="UTF-8"
path="script2.sql"
relativeToChangelogFile="true"
splitStatements="false"
stripComments="true"/>
</changeSet>
</databaseChangeLog>
主文件2:
<?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">
<include file="1.0.0.xml" relativeToChangelogFile="true"/>
<changeSet id="1.0.0" author="test" runAlways="true">
<tagDatabase tag="1.0.0"/>
</changeSet>
<include file="2.0.0.xml" relativeToChangelogFile="true"/>
<changeSet id="2.0.0" author="test" runAlways="true">
<tagDatabase tag="2.0.0"/>
</changeSet>
</databaseChangeLog>
我的跑步顺序:
Step1
liquibase updateToTag 2.0.0
--> Result: Scripts correctly installed on DB
Step2
liquibase updateToTag 2.0.0
--> Result: "AlwaysRun" scripts not re-ran on DB
知道为什么 liquibase 会忽略“runAlways”标签吗?谢谢
Liquibase 版本:4.6.1
【问题讨论】:
-
您可以粘贴您在第 1 步和第 2 步运行的所有命令吗?谢谢!
标签: sql-server database liquibase