✅ Short Answer
You apply a Liquibase migration using the update command from the CLI:
liquibase update
This command tells Liquibase to:
- Connect to your database
- Read the changelog file
- Apply any changesets that haven’t been run yet
🔎 Step-by-Step Command Line Usage
1. ✅ Basic Example
liquibase \
--changeLogFile=db/changelog.xml \
--url=jdbc:postgresql://localhost:5432/mydb \
--username=myuser \
--password=mypass \
update
This runs all unapplied changesets in changelog.xml.
2. ✅ Set Configuration Once (Optional)
Create a liquibase.properties file to avoid typing all parameters every time:
changeLogFile=db/changelog.xml
url=jdbc:postgresql://localhost:5432/mydb
username=myuser
password=mypass
driver=org.postgresql.Driver
Then you can run:
liquibase update
✅ Other Useful CLI Commands
| Command | Description |
|---|---|
update | Apply pending changesets |
updateCount 1 | Apply only the next 1 changeset |
updateSQL | Show the SQL that would be executed |
status | Show which changesets have not been applied |
rollbackCount 1 | Roll back the last 1 changeset |
tag my-release-v1 | Mark current DB state with a version tag |
history | Show execution history of applied changes |
clearCheckSums | Clear checksums if you edited a changeset |
🧠 Behind the scenes
- Liquibase checks the
DATABASECHANGELOGtable - Compares changesets against what’s already been applied
- Runs only new changesets (unless
runAlwaysorrunOnChangeis used)
📌 Key Takeaways
✅ Use the update command to apply migrations via the command line
✅ Prefer using a liquibase.properties file for reusability
✅ Useful for local dev, automation, or CI/CD pipelines
✅ Track progress and debug with commands like status, history, and updateSQL