liquibase update: Apply a Changelog in CI
liquibase update runs every changeset in the changelog that has not yet been applied to the target database.
update is the deploy command for Liquibase. It reads the changelog, checks the DATABASECHANGELOG table, and applies whatever is new.
What it does
liquibase update parses the changelog file, computes which changesets are already recorded in DATABASECHANGELOG, and executes the rest in order. Each applied changeset is recorded with its checksum (MD5SUM).
Common usage
liquibase \
--changelog-file=db/changelog.xml \
--url=jdbc:postgresql://db:5432/app \
--username=ci --password="$DB_PASSWORD" \
update
# properties file instead of flags
liquibase --defaults-file=liquibase.ci.properties updateOptions
| Flag | What it does |
|---|---|
| --changelog-file=<path> | Root changelog to apply |
| --url / --username / --password | Connection details |
| --contexts=<list> | Only run changesets tagged with these contexts |
| --labels=<expr> | Filter changesets by label expression |
| --defaults-file=<path> | Load options from a properties file |
In CI
Run update as a dedicated step before the app rolls out. Liquibase acquires a row in DATABASECHANGELOGLOCK so concurrent runners wait rather than conflict; if a job is killed mid-run the lock can stick and you clear it with liquibase releaseLocks.
Common errors in CI
"Validation Failed: 1 changesets check sum" (the MD5SUM mismatch) means an already-applied changeset was edited; revert it or run liquibase clearCheckSums. "Could not acquire change log lock. Currently locked by ..." means a prior run left DATABASECHANGELOGLOCK set; clear it with liquibase releaseLocks. "Unknown Reason" during a changeset usually wraps the underlying SQL error printed just above.