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.
For more information on MD5Sums
, see Changeset Checksums.
Controlling updates
There are several commands that apply a changeset that has not been run:
Command | Description |
---|---|
update | Updates database to current version. |
update-count | Applies the next <value> changesets. |
update-one-changeset | Targets and deploys any single changeset. |
update-testing-rollback | Updates the database, then rolls back changes before updating again. |
update-to-tag | Applies sequential changes to your database from the newest changeset to the changeset with the tag you specified and applied earlier. |
SQL update mode
Rather than applying changesets directly to the database, the required SQL can be stored for review and later application.