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

Version 1 Next »

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

General Usage

The following code will update your database using LiquiBase:

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

Some points to notice:

ClassLoaderResourceOpener

LiquiBase uses the concept of a liquibase.resource.ResourceOpener to abstract how files are accessed.  ClassLoaderResourceOpener is one option which will check your classpath for the specified changelog file and any other resources needed.  Other options include FileSystemResourceOpener which understands absolute paths, and CompositeResourceOpener which can combine and chain ResourceOpeners.  The ResourceOpener to use is passed to the 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()

Update will update the database.  Parameters can be passed to update to control contextsto execute.

  • No labels