Schema migration system for ZIO Schema 2#982
Conversation
…calls - Replace typeName with typeId in structural derivation macros - Use TypeId.nominal for structural types - Fix DynamicValue.Record to use varargs or Chunk instead of Vector - Fix MigrationValidator to use typeId.name instead of typeName.name
- Fix scalafmt issues in Scala 2 and Scala 3 migration files - Fix Scaladoc @throws annotation to use fully qualified name - Add MigrationValidatorSpec with 44 comprehensive tests - Add 25+ error path tests to DynamicMigrationSpec - Total migration tests increased from ~94 to ~166
- Add error aggregation tests for AtIndices, AtMapKeys, Elements, MapKeys, MapValues - Add DynamicSchemaExpr tests: StringConcat, StringLength, CoercePrimitive, Arithmetic ops - Add Logical/Relational operator tests - Add navigateDynamicValue coverage tests - Add Wrapped, AtMapKey, Case path navigation edge case tests - Add MigrationValidator path navigation tests for all optic types - Increase branch coverage to meet 80% minimum requirement
|
Ahmed seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
There was a problem hiding this comment.
Pull request overview
This PR implements a pure, algebraic schema migration system for ZIO Schema 2. The system enables type-safe schema evolution through serializable migrations that operate on DynamicValue, with compile-time validation and automatic reversibility. The implementation includes structural schema derivation for Scala 3, selector macros for ergonomic path expressions, and comprehensive build-time validation.
Changes:
- Core migration types:
Migration[A,B],DynamicMigration,MigrationActionADT,DynamicSchemaExpr, andMigrationError - Migration builder with fluent API and build-time validation via
MigrationValidator - Selector macros (Scala 2 & 3) for type-safe path expressions with optic-like syntax
- Structural schema derivation for Scala 3 (refinement types and union types)
- Comprehensive test suite with 1600+ tests covering all operations
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 |
|---|---|
| MigrationAction.scala | ADT for migration actions with 14+ action types and reversibility |
| DynamicMigration.scala | Untyped, serializable migration with path-based value transformation (744 lines) |
| Migration.scala | Typed migration wrapper providing type-safe API and composition |
| MigrationError.scala | Comprehensive error types with path information |
| DynamicSchemaExpr.scala | Serializable expressions for value transformations (594 lines) |
| MigrationBuilder.scala | Fluent builder API with default value resolution (631 lines) |
| MigrationValidator.scala | Build-time structural validation (693 lines) |
| SelectorMacros.scala | Scala 2 & 3 macros for type-safe selector expressions |
| MigrationBuilderSyntax.scala | Extension methods for ergonomic selector syntax |
| SchemaCompanionVersionSpecific.scala | Structural schema derivation for Scala 3 (196 new lines) |
| Selector.scala | Type-safe selector abstraction |
| package.scala | Package documentation |
| Structural bindings | Runtime support for structural types (Constructor, Deconstructor, Matcher) |
| Test files | 10+ comprehensive test specs covering all migration operations |
| JsonBinaryCodecDeriver.scala | Bug fix for recursive records (delayed initialization) |
| Test utilities | Newline normalization for cross-platform compatibility |
| Documentation | Migration reference guide with examples and best practices |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@jdegoes hi I was still working on the pr but i couldn't run the tests locally due to insufficient memory on my pc thats why i was pushing the changes and seeing if the checks will fail or not. thats why there are so many commits. |
Summary
Examples
Structural schema + addField
Selector grammar (paths)
MigrationBuilder[Old, New]
.dropField(.address.street)
.optionalizeField(.email)
.buildPartial
Notable behavior
Tests
Demo / Video
migration-demo.mp4
Notes / limitations
Review guide
Issues