The changelog file in Liquibase is the single source of truth for your database schema history. It is an ordered list of changesets, each describing one change such as creating a table or adding a column. Liquibase reads the changelog, compares it with the DATABASECHANGELOG table in the target database, and runs only the changesets that have not been applied yet.
That makes schema changes versioned, repeatable and reviewable in the same way as application code.
A changelog is a file in XML, YAML, JSON or formatted SQL. It holds changeSet entries, and each entry is identified by the combination of id, author and the file path. Liquibase stores that identity together with a checksum of the change in the DATABASECHANGELOG table after it runs.
Typical contents:
createTable, addColumn, createIndex, sql, and so on)include or includeAll entries that pull in other changelog filesLiquibase also creates a DATABASECHANGELOGLOCK table so that only one process migrates a database at a time.
A common layout is one root changelog that includes smaller files in order.
When Liquibase runs this, it creates the users table and inserts a row into DATABASECHANGELOG with the id, author, file name, execution time and checksum.
On every update, Liquibase follows these steps:
DATABASECHANGELOGLOCK.DATABASECHANGELOG.This is why you must not edit a changeset after it has been applied anywhere. Add a new changeset instead. The exceptions are runOnChange: true (re-run when the content changes, suitable for views or stored procedures) and runAlways: true.
| Format | Strengths | Trade-offs |
|---|---|---|
| YAML or JSON | Readable, database independent change types | Less control over vendor specific SQL |
| XML | Mature, full schema validation in IDEs | Verbose |
| Formatted SQL | Plain SQL, easy for DBAs | Tied to one database dialect |
Database independent formats let Liquibase generate the correct SQL per database, while formatted SQL gives you exact control. Many teams use YAML or XML for common changes and SQL files for vendor specific work.
With liquibase-core on the classpath, Spring Boot runs Liquibase at startup. The default location is classpath:/db/changelog/db.changelog-master.yaml, so you often need no configuration. To change it:
Outside Spring, use the command line:
Other useful commands are status (list pending changesets), updateSQL (print the SQL without running it), rollbackCount 1 and validate.
logicalFilePath attribute can pin it).sql changes.contexts and labels to separate data meant for test environments from production changes.updateSQL or status in CI against a throwaway database before production.A changelog is the file, or tree of files, that lists the changes. A changeset is one unit inside it, identified by id, author and file path, and applied exactly once per database.
In the DATABASECHANGELOG table of the target database, which stores one row per executed changeset with its checksum.
Liquibase detects the checksum change and fails validation. Add a new changeset, or use runOnChange where re-running is safe.
No. It has a command line, Maven and Gradle plugins and Spring Boot integration, but you can use it from any stack.
The Liquibase changelog is the ordered, version-controlled record of every schema change. Liquibase compares it with DATABASECHANGELOG to apply only what is missing, protects applied changes with checksums, and lets you roll changes forward and back consistently across environments.