Convert Liquibase XML to YAML? Convert Liquibase XML to YAML? xml xml

Convert Liquibase XML to YAML?


There is nothing built in, but you can easily do it with a little scripting.

Some starting points:liquibase.parser.ChangeLogParserFactory.getInstance().getParser(".xml", resourceAccessor).parse(...) will return a DatabaseChangeLog object representing the changelog file.

liquibase.serializer.ChangeLogSerializerFactory.getInstance().getSerializer(".ya‌​ml").write(...) will output the changeSets in the DatabaseChangeLog object out to a file in yaml format


I know this is a bit late of an answer; however, I was looking into using Liquibase for a project at work and was looking for something to do what he OP wanted. I saw Nathan Voxland's answer and made a command-line utility written in Java to convert this. The code can be found at here on Github. Feel free to modify it or fix it and send PRs; I literally wrote it in an hour or so, so please be easy on judging the code base :). Hopefully this will help out the next person that is looking for a similar tool and stumbles here.


Smart way is to directly generate yaml instead of xml, Liquibase provides this functionality OOB.You only need to change the extension of output changeLogFile file to .yaml and liquibase will understand you nicely (tested with liquibase-3.6.0).

For example: I ran this command for my Postgres DB:

liquibase --driver=org.postgresql.Driver           --classpath=\path\to\postgresql-9.0-801.jdbc4.jar          --changeLogFile=D:\Liquibase\changeLog.yaml           --url="jdbc:postgresql://localhost:5432/db_name"           --username=postgres           --password=postgres           --logLevel=debug generateChangeLog

Caution: New lines were added for readability purpose.

Now you know what will happen if you change the extension of output file to .xml

PS: If liquibase command doesn't work try the same with java -jar liquibase.jar.