Skip to content
AITroveRead. Build. Understand.
Make this comfortable

Spring Boot migration tests: distinguish a test starter from a runtime rollout

Last updated: 30 Sept 20264 min read
tutorial
IntermediateBy AITrove Editorial

A test-scoped migration starter can verify Boot auto-configuration without placing Flyway in the runnable application artifact.

Download Spring source kit

Two different fixtures

FlywayReceiptMigrationTest calls Flyway.configure directly and checks ordered SQL plus history. BootFlywayStartupTest uses spring-boot-starter-flyway on the test classpath and lets a separate Boot context perform migration during startup. These tests establish different things. Neither changes ReceiptApplication to a production database-backed API.

The SQL files live under src/test/resources/db/relay-migration. The test sets spring.flyway.locations explicitly; the files are not a default runtime migration directory. The source ZIP includes test sources so readers can run them locally. The ownership lesson explains what would have to change for a deployed application.

Test the artifact you ship

Before claiming production startup migrations, promote the chosen dependency and reviewed SQL into the runtime artifact, or use a separate deployment migration job. Pin the target database module as needed and check its actual DDL behavior. Then verify the final packaged artifact in a disposable environment.

Keep test seed data out of production migrations unless it is genuinely required. Here V1 inserts one receipt for a controlled exercise. A production seed policy needs a different decision and review.

Checked source

xml
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-flyway</artifactId>
  <scope>test</scope>
</dependency>

Verification boundary

BootFlywayStartupTest and FlywayReceiptMigrationTest; Maven dependency has test scope. The excerpt is shortened; the source kit contains the checked fixture.

Costs and limits

No production database module, runtime migration job, packaged ReceiptApplication integration or target-engine startup test exists.

Common Mistakes

  • Do not present the test starter as a runtime dependency.
  • Do not leave sample seed rows in a production release by accident.
  • Do not assume a passing H2 context validates another engine.

Read next

Spring Boot Flyway startup: apply versioned SQL before querying a receipt, Spring Boot and Flyway: choose who runs migrations before traffic starts, Flyway SQL migrations: record ordered schema changes against a real database, Spring schema rollout tests: check old and new writers at every phase.

spring
spring-boot
migration
Storage details