Managing database schema changes in modern applications can be complex, especially in microservices or cloud-native environments. One of the most efficient ways to handle this challenge is by using Liquibase, a powerful database migration tool. In this tutorial, weโll walk through how to implement Liquibase Spring Boot 3 migration effectively in your project.

๐ What is Liquibase?
Liquibase is an open-source database-independent library for tracking, managing, and applying database schema changes. It supports:
- SQL and XML-based changelogs
- Rollback capabilities
- Integration with Spring Boot, Maven, and CI/CD tools
๐ ๏ธ Why Use Liquibase with Spring Boot 3?
With Spring Boot 3, developers often move to Jakarta EE namespaces and modular architecture. Liquibase fits in perfectly by allowing schema changes to be automated and version-controlled, keeping the database in sync with the application codebase.
๐ฆ Setting Up Liquibase
1. Add Liquibase Dependency
In your pom.xml
, include:
1 2 3 4 5 6 7 |
<dependency> <groupId>org.liquibase</groupId> <artifactId>liquibase-core</artifactId> </dependency> |
2. Create a Master Changelog File
Inside src/main/resources/db/changelog/db.changelog-master.yaml
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
databaseChangeLog: - changeSet: id: 1 author: ketan changes: - createTable: tableName: users columns: - column: name: id type: BIGINT autoIncrement: true constraints: primaryKey: true - column: name: username type: VARCHAR(255) constraints: nullable: false - column: name: email type: VARCHAR(255) |
3. Configure application.yml
1 2 3 4 5 6 7 |
spring: liquibase: change-log: classpath:db/changelog/db.changelog-master.yaml enabled: true |
๐งช Verifying the Migration
Run your application using:
mvnw spring-boot:run
Liquibase will automatically apply the schema changes defined in the changelog to your configured database.
You can verify the generated tables (users
in this case) and Liquibase tracking tables like:
DATABASECHANGELOG
DATABASECHANGELOGLOCK
๐ Updating the Schema
To add a new column to the users
table:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
- changeSet: id: 2 author: ketan changes: - addColumn: tableName: users columns: - column: name: age type: INT |
Once the application is restarted or re-deployed, Liquibase Spring Boot 3 migration will detect the new changeset and apply it automatically.
๐งฑ Best Practices
- Use semantic
id
values in changeSets (e.g.,user-table-v1
) - Always test Liquibase migrations in a staging environment
- Use rollback statements for critical changes
- Keep changelog files modular (split into multiple files per module)
๐งฉ Conclusion
By integrating Liquibase Spring Boot 3 migration, you can ensure smooth, traceable, and automated database updates alongside your code. Whether you are working in a monolith or distributed system, this approach reduces risk and improves consistency.