Liquibase
Liquibase
Overview
Liquibase is an open source (Apache License), database independent management library with a database-backed version control system.
Liquibase tracks all database changes in one or more changelogs. Each changelog contains one or more changesets. Each changeset describes the changes that need to be applied to the database in a database independent manner. As Liquibase applies the changeset to your database, it writes a row in a DATABASECHANGELOG table indicating the changeset is applied. On subsequent executions, Liquibase compares the changesets in the changelog with the ones stored in DATABASECHANGELOG. If a changeset has already been applied, Liquibase will not reapply the change and will not add a new entry in DATABASECHANGELOG.
Liquibase creates a checksum for each changeset. Once you have applied a changeset to a database, it must not be edited in the changelog or Liquibase will require you to resolve the checksum mismatch.
For more information, see the Liquibase Manual.
To simplify database development, Elastic Path ships a Maven archetype which is used to build a "schema extension" project.
The Elastic Path 6.13.0 changelog is located at: <Elastic Path root>/liquibase/core-schema/src/main/resources/liquibase/core-changelog-6.12.0.xml
Liquibase enables you to generate database documentation. For instructions on how to generate your own documents, see Database Documentation.
Using Liquibase in Maven (Liquibase Maven Plugin)
All Liquibase Maven commands must be executed from the project which is using Liquibase, usually your schema extension project. Prior to running the Liquibase plugin, ensure you run the following command first:
mvn package
Below is a subset of useful Mavenized Liquibase commands:
Maven Goal | Task | Example |
---|---|---|
status | Displays in the command prompt which changesets need to be applied to the database | mvn package liquibase:status |
update | Applies changesets to the database | mvn package liquibase:update |
dbDoc | Generate an HTML report of changes that have been applied and need to be applied to the database. | mvn package liquibase:dbDoc |