I would like to add lifecycle logging before, after, as well as on failed migrations.
To implement this, I planned to register a liquibase.changelog.visitor.ChangeExecListener on the Liquibase instance.
I found that the SpringLiquibase initialization bean fully encapsulates the migration.
So, to register an ChangeExecListener in the Liquibase instance, I only see the option to:
- Inherit SpringLiquibase and override createLiquibase.
- Copy the LiquibaseAutoConfiguration into our codebase and return the inherited SpringLiquibase in LiquibaseAutoConfiguration.LiquibaseConfiguration#createSpringLiquibase.
Versions used: - Spring Boot: 3.1.4 - Liquibase: 4.22.0
Do you know of any other way to register custom logic, such as logging before, after, and on failed migrations?
Comment From: wilkinsona
I agree with your analysis. Sub-classing SpringLiquibase and overriding createLiquibase seems to be the only configuration option. You may want to raise a Liquibase enhancement request to introduce a customization mechanism. Perhaps a LiquibaseCustomizer interface could be introduced. Customizer instances could be added to SpringLiquibase and they could then be called in createLiquibase. This would remove the need for sub-classing. If Liquibase offered this functionality, Spring Boot could then auto-configure the SpringLiquibase instance with any customizer beans.
I'll close this for now as this requires a change in Liquibase that is out of our control. If such a change is made in the future please let us know and we can re-open this issue and look at making use of it.
Comment From: asashour
Liquibase 4.28.0 has the needed change.
Please re-open this ticket, and a PR would be raised once Liquibase is upgraded.
Comment From: wilkinsona
Thanks, @asashour. I've re-opened the issue and updated its title to describe the desired change.
Comment From: wilkinsona
Closing in favor of #40986.