Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Purpose

liquibase.parser.ChangeLogParser implementations allow you to read database changelog files written in different formats.  The default changelog format is XML based, but there is nothing inherently XML in the LiquiBase internals.

Examples

  • A parser for a LiquiBase DSL
  • A parser to read database changes stored in a 3rd party system

How to Create

Custom parsers must implement liquibase.parser.ChangeLogParser, which includes the following methods:

public String[] getValidFileExtensions();

Returns the file extensions this parser understands.  When LiquiBase is fed a change log file, it will choose the parser based on the file extension.

public DatabaseChangeLog parse(String physicalChangeLogLocation, Map<String, Object> changeLogParameters, FileOpener fileOpener) throws ChangeLogParseException

Does the work of parsing a given changelog file into the internal DatabaseChangeLog object structure used by the rest of LiquiBase.

Registering Custom Parsers

There are two ways to register a custom ChangeLogParsers:

  1. Create the class in a sub-package of "liquibase.parser.ext".  LiquiBase automatically registers Databases it finds in that package
  2. Call liquibase.parser.ChangeLogParserFactory.getInstance().register(yourParser)

Threading/Singleton notes

ChangeLogParsers implementations should be created thread safe.  Once an instance of a ChangeLogParser registered, ChangeLogParserFactory will continue to use the return instance.

  • No labels