Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Liquibase: How to disable FILENAME column check?

Tags:

liquibase

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?

like image 787
snowindy Avatar asked Nov 13 '13 16:11

snowindy


3 Answers

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.

like image 109
snowindy Avatar answered Sep 19 '22 11:09

snowindy


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

like image 44
Patrick Avatar answered Sep 18 '22 11:09

Patrick


@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.

like image 23
Nathan Voxland Avatar answered Sep 19 '22 11:09

Nathan Voxland