This example shows how to use liquibase in springboot to manage the history of changes to the database schema as a result of application changes., having:
-
Spring liquibase h2-db(embeded), mysql
-
Spring actuator liquibase migration state
-
Spring @Bean CommandLineRunner check
To try the example, execute this command in a terminal: As running container, it runs two sql files. DML sql file consists of five lines of book information. You should now be able to see migration infomation in terminal spring log after the beans autoconfiguration.
mvn clean spring-boot:run
The difference between this example and "flyway example" is table migration process owner is liquibase, not JPA. liquibase will include validation. Therefore, you must turn off the Hibernate Validation setting as follows:
spring.jpa.hibernate.ddl-auto = none
You can check liquibase migration state in springboot actuator after container running complete:
http://localhost:7979/actuator/liquibase
Let 's see springboot embeded h2-console UI: You can check the operation history in DATABASECHANGELOG table created after migration.
http://localhost:8989/h2-console
If you want to test your own mysql server, change spring.datasource configuration in application.properties
Reference - [1]. http://www.liquibase.org/documentation/changes/