Implements a pure, algebraic migration system for ZIO Schema that represents
structural transformations between schema versions as first-class, serializable
data. Unlike traditional migration approaches, this system uses no functions,
closures, or reflection - migrations are pure ADTs that can be stored,
inspected, and applied dynamically.
// Build a type-safe migration
val migration = MigrationBuilder.withFieldTracking[PersonV1, PersonV2]
.renameField(select(_.name), select(_.fullName))
.keepField(select(_.age))
.addField(select(_.country), "US")
.build // Only compiles when all fields are handled
// Apply migration
migration.apply(v1) // Right(PersonV2(...))
// Reverse migration
migration.reverse.apply(v2) // Right(PersonV1(...))
// Nested migrations
val migration = MigrationBuilder.withFieldTracking[PersonV0, PersonV1]
.keepField(select(_.name))
.inField(select(_.address), select(_.address))(addressMigration)
.build
Migration Actions
Category: Record
Actions: AddField, DropField, Rename, TransformValue, Mandate, Optionalize,
ChangeType
────────────────────────────────────────
Category: Enum
Actions: RenameCase, TransformCase
────────────────────────────────────────
Category: Collection
Actions: TransformElements, TransformKeys, TransformValues ────────────────────────────────────────
Category: Nested
Actions: TransformField, TransformEachElement, TransformEachMapValue
24 spec files covering:
fixes #519 /claim #519
Aqil Ahmad
@Aqil-Ahmad
marianaguzmanguerrero16-dev
@marianaguzmanguerrero16-dev
ZIO
@ZIO