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

Spring exercise: predict file overrides and three migration versions

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

A release trace records the bound worker settings and the receipt writes that remain legal at each migration version.

Download Spring source kit

Settings trace

Start with programmatic defaults batchSize=8 and timeout=2s. Add a file with batchSize=17 and timeout=750ms. The bound record becomes 17 and 750ms. Add the command-line argument --relay.batch-size=23. The bound record becomes 23 and 750ms. The two BootRelaySettingsTest file cases check those exact states. Replace the command-line value with zero and startup fails validation.

For each state, write the effective value, its source and whether a worker may start. Do not infer that an absent mounted file was read from the presence of an acceptable default. The collision lesson explains the checked row.

Database trace

At V1, tenant_id does not exist. At V2, the old insert omitting tenant_id succeeds and leaves null. At V3, migration backfills existing null rows and requires tenant_id on future inserts. The old insert then fails; a new insert with east succeeds. Record the count of applied versions as 1, 2 and 3. A repeated migrate at V3 executes zero files.

Now change the recorded checksum for V2 in a disposable test database and run validate. Expect a validation exception before another release proceeds. Explain why rewriting history is not the repair plan. Run the named Maven tests and compare your trace with their assertions; the exercise has no hosted judge.

Checked source

bash
mvn -q -Dtest=BootRelaySettingsTest,FlywayReceiptMigrationTest test

Verification boundary

BootRelaySettingsTest and FlywayReceiptMigrationTest. The excerpt is shortened or a labelled design sketch; the kit contains the checked tests.

Costs and limits

The trace uses a local file and H2 migrations. It does not prove mounted-secret behavior, target-engine DDL, mixed-version deployment timing or recovery after a process kill.

Common Mistakes

  • Do not carry the file batch size through a later command-line override.
  • Do not expect an old writer to work after V3 requires tenant_id.
  • Do not describe a checksum mismatch as a row-data error.

Read next

Spring Boot external config file: bind the value the process actually loads, Spring Boot file versus command line: assert the bound result, Flyway expand and contract: show exactly when an old writer breaks, Flyway validation: detect a changed applied migration before another write.

spring
spring-boot
migration
Storage details