Liquibase's DbDoc listing all changes as "Pending / Not yet ran" -
liquibase integrated our spring application , database migration executed during application startup phase.
when running dbdoc via maven plugin changes reported "pending changes (not yet ran)". cannot create diff view our next release.
the issue found spring bean uses classpath relative path changelog entries in databasechangelog table. when running dbdoc via maven plugin filepath relative maven project's root used.
the code of notranchangesetfilter cannot deal difference: http://grepcode.com/file/repo1.maven.org/maven2/org.liquibase/liquibase-core/3.3.2/liquibase/changelog/filter/notranchangesetfilter.java
particularly following comparison not work:
ranchangeset.getchangelog().equalsignorecase(changeset.getfilepath())
the methods return following values:
getchangelog(): classpath:changelog/5.3.3/nos_add_acp_data.xml getfilepath(): src/main/resources/changelog/5.3.3/nos_add_acp_data.xml
thus equalsignorecase comparison fails, results in changes being listed "pending / not yet ran".
is there known work-around? solution can imagine provide our own implementation of notranchangesetfilter , put on classpath before liquibase maven plugin gets executed. there other ideas or official fix this?
update 2015-04-30: after lot of debugging think path in databasechangelog table must normalized, before stored. additionally each tool must normalize path comparisons work. found following places in code comparisons fail current concept:
- ranchangesetfilter.getranchangeset(): equalsignorecase() comparison
- validatingvisitor.visit(): ranindex.get(changeset.tostring(false));
- notranchangesetfilter.accepts(): equalsignorecase() comparison
- ranchangeset.issame(): equalsignorecase() comparison
in latter there single "normalize()" method strips classpath: prefix path. in 1 of 4 places.
the dbdoc tool seems able work source code path relative maven project root , classpath path. there following configuration options in maven project:
<changelogfile>changelog/complete.xml</changelogfile> -> "classpath:" prefix missing in comparison <changelogfile>src/main/resources/changelog/complete.xml</changelogfile> -> "src/main/resources" prefix in comparisons
btw, first optiom should documented in maven plugin documentation.
pull request make dbdoc maven plugin work: https://github.com/liquibase/liquibase/pull/413
regards, michael
you right difference due differences in filepath liquibase stores. each changeset identified combination of id+author+filepath need ensure filepath consistent across ways of running liquibase.
usually best way have changelog files in classpath , refer changelogs using paths relative classpath, such "changelog/5.3.3/nos_add_acp_data.xml".
i'm not sure how referencing files currently. if using 3.3.2, there issue related how includeall works spring has been addressed in 3.3.3 may running into.
otherwise, can use "logicalfilepath" attribute on root databasechangelog node hard-code liquibase uses path know same, referenced.
Comments
Post a Comment