如何修改liquibase中sql脚本的默认执行顺序?
How to modify the default execution order of sql script in liquibase?
我正在尝试 运行 Liquibase 中的一堆 sql 脚本。但是,默认情况下,liquibase 会按照它们在目录中的顺序执行所有脚本。有什么方法可以改变这些脚本的执行默认执行,即先通过创建 table 脚本执行,然后再执行所有插入脚本。
我的主更新日志文件:
<?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">
<includeAll path="../migration/" relativeToChangelogFile="true"/>
</databaseChangeLog>
我将所有 sql 脚本放在迁移文件夹中。
您不能修改执行顺序。您唯一可以做的就是通过重命名来更改 /migration
目录中文件的顺序。
据我所知,Liquibase 按字母顺序对文件进行排序。
并且在文件内部,Liquibase 从上到下逐一执行 changeSets。
或
您可以使用 <include>
而不是 <includeAll>
。这样您就可以按照您需要的顺序包含 changeLog 文件。
<?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">
<include file="../migration/changeLog_3.xml" relativeToChangelogFile="true"/>
<include file="../migration/changeLog_1.xml" relativeToChangelogFile="true"/>
<include file="../migration/changeLog_2.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>
我正在尝试 运行 Liquibase 中的一堆 sql 脚本。但是,默认情况下,liquibase 会按照它们在目录中的顺序执行所有脚本。有什么方法可以改变这些脚本的执行默认执行,即先通过创建 table 脚本执行,然后再执行所有插入脚本。
我的主更新日志文件:
<?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">
<includeAll path="../migration/" relativeToChangelogFile="true"/>
</databaseChangeLog>
我将所有 sql 脚本放在迁移文件夹中。
您不能修改执行顺序。您唯一可以做的就是通过重命名来更改 /migration
目录中文件的顺序。
据我所知,Liquibase 按字母顺序对文件进行排序。
并且在文件内部,Liquibase 从上到下逐一执行 changeSets。
或
您可以使用 <include>
而不是 <includeAll>
。这样您就可以按照您需要的顺序包含 changeLog 文件。
<?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">
<include file="../migration/changeLog_3.xml" relativeToChangelogFile="true"/>
<include file="../migration/changeLog_1.xml" relativeToChangelogFile="true"/>
<include file="../migration/changeLog_2.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>