Schema migration system for ZIO Schema 2#984
Closed
Godzilla675 wants to merge 12 commits intozio:mainfrom
Closed
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements a comprehensive pure, algebraic schema migration system for ZIO Schema 2, enabling type-safe transformations between schema versions as first-class, serializable data.
Changes:
- Introduces core migration types (Migration, DynamicMigration, MigrationAction, DynamicSchemaExpr) with full serialization support
- Adds MigrationBuilder with fluent API, default value resolution, and structural validation
- Implements selector macros for type-safe optic-style paths in both Scala 2 and 3
- Adds Schema.structural derivation for compile-time-only structural types (Scala 3)
- Provides comprehensive test coverage with 1000+ tests across multiple spec files
Reviewed changes
Copilot reviewed 38 out of 38 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| DynamicMigration.scala | Core untyped migration engine operating on DynamicValue with path-based action application |
| Migration.scala | Typed migration wrapper with schemas, providing type-safe apply/compose/reverse operations |
| MigrationAction.scala | ADT of migration actions (AddField, RenameField, etc.) with structural reverse operations |
| DynamicSchemaExpr.scala | Serializable expression DSL for value transformations (arithmetic, logic, coercion) |
| MigrationBuilder.scala | Fluent builder API with build-time default value resolution and validation hooks |
| MigrationValidator.scala | Structural validation engine simulating actions on schema structures |
| MigrationError.scala | Path-aware error types for diagnostics |
| SelectorMacros.scala (2/3) | Compile-time conversion of lambda selectors to DynamicOptic paths |
| MigrationBuilderSyntax.scala (2/3) | Extension methods for type-safe selector syntax |
| SchemaCompanionVersionSpecific.scala | Adds Schema.structural derivation for refinement/union types (Scala 3 only) |
| Various binding classes | Adds StructuralMatcher/Constructor/Deconstructor for compile-time-only types |
| Test files | Comprehensive test coverage for all migration operations and edge cases |
| migration.md | Complete documentation with examples and best practices |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…structure comparison - Add validatePath/validatePathRecursive to check Wrap path segments match schema structure - Validate Elements only on sequences, MapKeys/MapValues only on maps, Case only on variants - Add lenient structure comparison mode when structural migration actions are present - Handle Split/Join/Mandate/Optionalize by relaxing field presence checks - Preserve optionality checking for Dynamic fields even in lenient mode - Fix error message format for optionality and structure mismatches Fixes 13 failing MigrationValidatorSpec tests and 1 MigrationValidatorOptionalitySpec test.
Contributor
Author
|
@jdegoes why did you close the pr? at least give feedback I am still working on it. |
This was referenced Feb 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Examples
Structural schema + addField
Selector grammar (paths)
MigrationBuilder[Old, New]
.dropField(.address.street)
.optionalizeField(.email)
.buildPartial
Notable behavior
Tests
Notes / limitations
Review guide
Issues