Migrations only describe a database as long as nobody changes it any other way. Then someone adds a column during an incident, a DBA widens a type, a data import relaxes a constraint, and nobody writes it down. The next migration was tested against a database that production no longer is.
That gap is called drift. This article makes four changes by hand on a production database, finds them with migrax drift , keeps the one that was wanted, undoes the rest, and then makes the application refuse to start on a database that has drifted.
Tested with: Migrax 0.17.1, Spring Boot 3.5.7, Hibernate 6.6.33, PostgreSQL 17. Every output below was copied from a real run; log lines are shortened to the message.
The starting point
A Spring Boot application with a customers table, built by two migrations and applied to production:
@Entity @Table ( name = "customers" ) public class Customer { @Id @GeneratedValue ( strategy = GenerationType .…