https://github.com/h3yzack/springboot3-liquibase-example
Spring Boot 3.x with Liquibase example project
https://github.com/h3yzack/springboot3-liquibase-example
java java-19 liquibase maven postgresql spring spring-boot
Last synced: 13 days ago
JSON representation
Spring Boot 3.x with Liquibase example project
- Host: GitHub
- URL: https://github.com/h3yzack/springboot3-liquibase-example
- Owner: h3yzack
- Created: 2023-02-25T21:43:07.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-25T22:14:56.000Z (almost 3 years ago)
- Last Synced: 2023-11-03T02:34:05.618Z (over 2 years ago)
- Topics: java, java-19, liquibase, maven, postgresql, spring, spring-boot
- Language: Java
- Homepage:
- Size: 61.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Spring Boot 3 Liquibase Example
This project demonstrates how to use Liquibase with Spring Boot 3 to manage database schema changes and generate SQL diff scripts from JPA entities. Both Gradle and Maven build settings are included, so either tool can be used to generate changelogs and apply updates to the database.
## Requirements
- Java 21
- PostgreSQL Database
- Gradle 8.5+ or Maven 3+
## Dependencies
- Spring Boot 3.5.5
- Liquibase Core 4.31.1
- Liquibase Hibernate 4.31.1
- PostgreSQL JDBC Driver 42.7.7
- Lombok (optional, for code generation)
## Usage
### Start the Service
```sh
./mvnw spring-boot:run
# or
./gradlew bootRun
```
### Generate Database Changelog and SQL Diff
#### With Gradle
- Generate a diff changelog SQL file (from current DB and entities):
```sh
./gradlew diffChangeLog -Pdiff.version=1.0.0 -Pauthor=example
```
This will create a file like `src/main/resources/db/changelog/migration/_1.0.0_migrate.sql`.
- Apply the changelog to the database:
```sh
./gradlew update
```
#### With Maven
- Generate a diff changelog SQL file:
```sh
./mvnw liquibase:diff -Ddiff.version=1.0.0
```
The generated file will be in `src/main/resources/db/changelog/migration/_1.0.0_migrate.sql`.
- Apply the changelog to the database:
```sh
./mvnw liquibase:update
```
## Notes
- Database connection and Hibernate settings are configured in `src/main/resources/liquibase.properties`.
- The changelog master file is at `src/main/resources/db/changelog/db.changelog-master.yaml` and includes all migration scripts in the `migration` folder`.