Package com.onec.migration
Interface AppMigration
public interface AppMigration
A one-time, versioned data migration — the home for backfills, data reshaping and seed
data that the automatic schema upgrader cannot derive from metadata.
Declare implementations as Spring beans; the framework runs unapplied migrations in
version() order at startup (after the schema upgrade) and records each in
onec_schema_history so it executes exactly once per database, even with several
application instances starting concurrently.
@Component
public class BackfillWarehouseCodes implements AppMigration {
public String version() { return "2026.06.001"; }
public void migrate(MigrationContext context) {
context.handle().execute("UPDATE catalog_warehouses SET code_prefix = 'WH' WHERE code_prefix IS NULL");
}
}
Versions compare segment-wise (2 < 10); any dot-separated scheme works as long
as it sorts the way you intend. Each migration runs inside a transaction together with its
history record, so a failure rolls both back — but note that engines without transactional
DDL (H2, MySQL) auto-commit DDL statements mid-transaction.
-
Method Summary
Modifier and TypeMethodDescriptiondefault StringShort human-readable label stored in the history table.voidmigrate(MigrationContext context) version()Unique, stable version this migration is recorded under (e.g.