Menu

Spring Boot: migrations at startup, health checks and metrics
📰

Spring Boot: migrations at startup, health checks and metrics

DEV Community: postgres·Feroz Shah·23 days ago
#w9nrCzRw
#devtopostgresql#devto#dev#migrax#migration
Long article (1752 words) — no AI summary yet.
Reading 0:00
15s threshold

Migrations are written in development, but they have to run wherever the application runs: on a colleague's laptop, in CI, in staging, in production. The simplest way to get there is to let the application apply them itself, each time it starts, before anything else touches the database.

This article adds the Migrax starter to a Spring Boot application, follows what happens at startup, starts two instances at once, and looks at what Actuator shows: a health check and Prometheus metrics. At the end, the pipeline runs the migrations instead of the application.

Tested with: Migrax 0.17.1, Spring Boot 3.5.7, Hibernate 6.6.33, Micrometer 1.15.5, PostgreSQL 17. Every output below was copied from a real run; log lines are shortened to the message.

The setup

A shop with two entities, Customer and PurchaseOrder .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.