Updating the database

Liquibase allows you to apply database changes you and other developers have added to the changelog file.

How changeset statuses are tracked

Each changeset has an Id and author attribute which, along with the directory and file name of the changelog file, uniquely identifies it.

Liquibase reads the changeset in the changelog file sequentially and compares the identifier to the values stored in the DATABASECHANGELOG table. If the identifier does not exist in the table, the changeset is run and a new row is added to the DATABASECHANGELOG table containing the identifier and an MD5Sum hash of the changeset.

If the identifier already exists in the DATABASECHANGELOG table, the MD5Sum of the changeset as it currently exists is compared to the one in the database. If they are different, Liquibase will either throw an error alerting you that someone has changed it unexpectedly, or re-executes it depending on the status of the runOnChange changeset attribute.

Controlling updates

There are two modes for applying a changeset that has not been run:

  • update - which applies all changes that have not been run.
  • updateCount - which applies just a given number of changes that have not been run.

SQL update mode

Rather than applying changesets directly to the database, the required SQL can be stored for review and later application.