Summary

This PR implements a pure, algebraic migration system for ZIO Schema that represents structural transformations between schema versions as first-class, serializable data.

Key Features

  • Pure Data Migrations: All migrations are represented as case classes with no closures, making them fully serializable
  • Hierarchical Actions: Supports nested migrations via AtField, AtCase, AtElements, enabling migrations like _.address.street -> _.address.streetName
  • Bidirectional: Every migration has a structural reverse
  • Introspectable: Migration logic can be inspected, transformed, and used to generate DDL, upgraders, or downgraders

Architecture

  • DynamicMigration: Untyped, fully serializable core that operates on DynamicValue
  • Migration[A, B]: Typed wrapper with schemas for compile-time safety
  • MigrationAction: Hierarchical ADT with “lists of lists” structure for nested migrations (the key innovation per @jdegoes feedback)
  • ResolvedExpr: Pure expressions for value-level transformations (no closures)
  • MigrationBuilder: Fluent API for constructing migrations

Example Usage

import zio.blocks.schema.migration._
case class PersonV1(firstName: String, lastName: String)
case class PersonV2(fullName: String, age: Int)
val migration = MigrationBuilder[PersonV1, PersonV2]
.joinFields(Vector("firstName", "lastName"), "fullName",
ResolvedExpr.concatWith(" ")(
ResolvedExpr.field("firstName"),
ResolvedExpr.field("lastName")
))
.addFieldInt("age", 0)
.build
// Nested migrations
val nestedMigration = MigrationBuilder[WithAddressV1, WithAddressV2]
.atField("address")(
_.renameField("street", "streetName")
.addFieldString("zipCode", "00000")
)
.build

Test plan

  • All 33 migration tests pass on Scala 3
  • All 33 migration tests pass on Scala 2.13
  • Existing schema tests still pass
  • CI passes

/attempt #519 /claim #519

Claim

Total prize pool $4,000
Total paid $0
Status Pending
Submitted January 31, 2026
Last updated January 31, 2026

Contributors

YU

Yuvraj Angad Singh

@yuvrajangadsingh

100%

Sponsors

ZI

ZIO

@ZIO

$4,000