For our application we use liquibase. We 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?
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.
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
@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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With