Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The class liquibase.Liquibase is designed as a facade to the library for use in integrations.  All functionality of LiquiBase Liquibase can be accessed starting with this class, in a simplified manner.

...

The following code will update your database using LiquiBaseLiquibase:

Code Block

Liquibase liquibase = new Liquibase(changelog, new ClassLoaderResourceAccessor(), DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection));
liquibase.update();

...

ClassLoaderResourceAccessor

LiquiBase Liquibase uses the concept of a liquibase.resource.ResourceAccessor to abstract how files are accessed.   ClassLoaderResourceAccesor is one option which will check your classpath for the specified changelog file and any other resources needed.  Other options include FileSystemResourceAccessor which understands absolute paths, and CompositeResourceAccessor which can combine and chain ResourceAccessormultiple ResourceAccessors.  The ResourceAccessor to use is passed to the LiquiBase Liquibase constructor.

DatabaseFactory.getInstance().findCorrectDatabaseImplementation

The simplest way to get a liquibase.database.Database object, which serves as the database abstraction layer, is by the DatabaseFactory.  You can pass a connection to it and receive back the connection wrapped in a Database object.

...

Update will update the database.  Parameters can be passed to update to control contextsto execute and labels, which in turn control which changesets are considered.

Other methods on the Liquibase facade are documented in the Javadocs.