✅ Short Answer
Liquibase tracks applied changes by recording each successfully executed changeset in a special database table called DATABASECHANGELOG.
Each entry includes metadata like id, author, filename, checksum, and execution timestamp.
🔎 Detailed Explanation
When you run liquibase update, Liquibase:
- Reads your changelog file(s)
- For each
<changeSet>:- Checks if it’s already listed in the
DATABASECHANGELOGtable - Compares the checksum to detect changes
- Checks if it’s already listed in the
- Executes the changeset only if it hasn’t been run yet, or if you’ve specified
runAlwaysorrunOnChange - Records a new row in
DATABASECHANGELOGafter successful execution
📋 Key Columns in DATABASECHANGELOG
| Column | Purpose |
|---|---|
ID | The unique ID from the changeset |
AUTHOR | Author name from the changeset |
FILENAME | Changelog file name where the changeset is defined |
DATEEXECUTED | Timestamp when this changeset was run |
ORDEREXECUTED | Order of execution |
MD5SUM (checksum) | Verifies if the changeset content has been modified |
EXECTYPE | EXECUTED, FAILED, SKIPPED, etc. |
DESCRIPTION | Description of the change (optional) |
🧠 Why is this important?
- ✅ Ensures each changeset runs exactly once
- ✅ Supports safe retries — rerunning
updatewon’t re-apply executed changesets - ✅ Detects unauthorized or accidental modifications via checksum mismatch
- ✅ Enables rollback, tagging, auditing, and repeatable deployments
🔄 Related Concepts
- Checksum mismatch → means the changeset was edited after execution
clearCheckSumscommand → resets checksums if you deliberately modified a changeset and want Liquibase to accept the new versionrunOnChange="true"→ Liquibase re-applies the changeset if the checksum changes (use with caution)
📌 Key Takeaways
✅ Liquibase uses the DATABASECHANGELOG table to track exactly which changesets were applied, when, and in what order.
✅ This mechanism ensures idempotency, auditability, and integrity of schema changes across environments.
✅ You never need to manually track what’s been applied — Liquibase does it all.