Liquibase: How to disable FILENAME column check?

一个人想着一个人 提交于 2020-06-27 07:28:32

问题


For our application we liquibase and may have a need to run DB migrations both from command line (manually on production) AND automatically as the application starts up (test environment etc).

The problem is that Liquibase considers the whole filename as a portion of a changeSet's identity, therefore it tries to reapply the changesets if the path is different. For example, in case of "fully qualified path" VS "relative path" to to the db-changelog file.

How to disable FILENAME column check?


回答1:


Based on this, the approach is as follows:

Always use the logicalFilePath attribute on both the databaseChangeLog element and every changeSet element.

Example:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog logicalFilePath="does-not-matter" 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-2.0.xsd">

    <changeSet logicalFilePath="path-independent" author="authorId" id="1">
        ...
    </changeSet>

</databaseChangeLog>

As result, FILENAME column for all changesets will contain 'path-independent' and check will be omitted.




回答2:


@snowindy's answer is good. Alternately, you can always refer to your changeLogs in a classpath-relative manner such as com/example/changelog.xml. if you configure the classpath correctly in both environments the same "com/example/changelog.xml" can be used.




回答3:


There's another factor that comes into play. There are different ways to reference the changeLogFile (absolute/relative path or by classpath). I wrote about it in detail here: https://stackoverflow.com/a/45644695/4176104



来源:https://stackoverflow.com/questions/19959755/liquibase-how-to-disable-filename-column-check

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!