我正在嘗試使用liquibase-maven-plugin來運行我的數據庫更新。我有以下插件配置:liquibase-maven-plugin和sqlFile
<configuration>
<username>${dba.username}</username>
<password>${dba.password}</password>
<url>${caesium.url}</url>
<changeLogFile>master.xml</changeLogFile>
<driver>org.postgresql.Driver</driver>
<includeArtifact>true</includeArtifact>
</configuration>
我將我的數據庫更新日誌(和SQL)文件保存在src/main/resources中。我的變更如下:
master.xml:
<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="baseline.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>
baseline.xml:
<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="base-roles" author="asdf" dbms="PostgreSQL">
<sqlFile path="sql/some-file.sql" relativeToChangelogFile="true"/>
</changeSet>
</databaseChangeLog>
的一些-file.sql是,在資源的SQL子目錄(這樣規定,相對於更新日誌,它是 sql/some-file.sql)。
唉!上述構造不起作用! sql文件不能被liquibase找到。
奇怪的是,當我將主腳本設置爲絕對路徑時,一切正常。但是,這不是我想要做的(我不想在數據庫更改日誌表中擁有絕對路徑)。
哦......我想我知道問題是什麼:如果主腳本不在子目錄中,liquibase無法計算出'base'目錄。把所有東西都移到更深處(這樣我的master.xml就是foo/master.xml),解決了這個問題。 – ishi
您可以使用'$ {project.basedir}'來避免硬編碼項目的名稱。 – Tunaki
我想了解您是如何設法解決它的,'master.xml'和'baseline.xml'是否駐留在同一目錄中? 'sql'文件夾的位置如何?你可以提供目錄結構嗎?謝謝 – Thracian