#Custom HealthIndicator for a liquibase database migration?

1 messages · Page 1 of 1 (latest)

chrome hound
#

Hi,

Is it possible to add a custom HealthIndicator for when a particular liquibase migration has completed?

Problem: Currently my docker-compose file runs a bunch of services, and one of the profiles which combines all the services have a command which execute 3 scripts. One of these scripts tries to access a database table, but it doesn't exist before the backend service has completed its liquibase migration. In Docker, I already tried adding a "healtcheck" and "depends_on", but it currently only checks for the normal health of the application as returned by Spring Boots default health actuator.

I need to somehow extend it to check whether or not the liquibase database migration in the Java backend app has actually completed. How can I extend the health actuator to depend on this migration being done?

The app is written using Groovy/Grails, which I believe is build on top of Java/Spring Boot, so it must have access to the same.

austere pineBOT
#

<@&987246584574140416> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
Hi, Is it possible to add a custom HealthIndicator for when a particular liquibase migration has completed? Problem: Currently my docker-compose file runs a bunch of services, and one of the profiles which combines all the services have a command which

omposed application starts up before liquibase has finished running its database migration scripts. I would like to create a custom HealthIndicator in Spring Boot to check if the liquibase migration has completed successfully before allowing requests to the application.

Solution: Yes, it is possible to create a custom HealthIndicator in Spring Boot to check if a specific liquibase migration has completed. You can create a custom HealthIndicator class that checks the status of the liquibase migration by querying the database or checking for specific table or data changes that indicate the migration has completed.

Here is an example of how you can implement a custom HealthIndicator for liquibase:

  1. Create a new class that implements the HealthIndicator interface provided by Spring Boot.
  2. Override the health() method to check the status of your liquibase migration and return an appropriate Health object based on the result.
  3. Use this custom HealthIndicator in your application configuration to monitor the status of your liquibase migration during application startup.

By using a custom HealthIndicator, you can ensure that your Spring Boot application waits for the liquibase migration to complete before starting up, thereby preventing any potential issues caused by incomplete database migrations.

undone meteor
#

well, if a mandatory migration fails, the application just won't start