Migration

zio.blocks.schema.migration.Migration
See theMigration companion object
final case class Migration[A, B](sourceSchema: Schema[A], targetSchema: Schema[B], dynamicMigration: DynamicMigration)

A typed migration that transforms values from type A to type B.

Migration[A, B] provides a type-safe wrapper around DynamicMigration, handling the conversion between typed values and DynamicValue automatically.

The migration process:

  1. Convert input A to DynamicValue using sourceSchema
  2. Apply the dynamicMigration to transform the dynamic value
  3. Convert the result back to B using targetSchema

The schemas can be any Schema[A] and Schema[B], including:

  • Regular schemas derived from case classes/enums
  • Structural schemas (JVM only) for compile-time-only types

This allows migrations between current runtime types and past structural versions without requiring old case classes to exist at runtime.

Type parameters

A

The source type

B

The target type

Value parameters

dynamicMigration

The underlying untyped migration

sourceSchema

Schema for the source type (can be structural or regular)

targetSchema

Schema for the target type (can be structural or regular)

Attributes

Companion
object
Source
Migration.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def ++[C](that: Migration[B, C]): Migration[A, C]

Compose this migration with another, applying this migration first, then the other.

Compose this migration with another, applying this migration first, then the other.

Value parameters

that

The migration to apply after this one

Attributes

Returns

A new migration that applies both in sequence

Source
Migration.scala

Get the list of actions in this migration.

Get the list of actions in this migration.

Attributes

Source
Migration.scala
def andThen[C](that: Migration[B, C]): Migration[A, C]

Alias for ++.

Alias for ++.

Attributes

Source
Migration.scala
def apply(value: A): Either[SchemaError, B]

Apply this migration to transform a value from type A to type B.

Apply this migration to transform a value from type A to type B.

Value parameters

value

The input value to migrate

Attributes

Returns

Either a SchemaError or the migrated value

Source
Migration.scala
def isEmpty: Boolean

Returns true if this migration has no actions (identity migration).

Returns true if this migration has no actions (identity migration).

Attributes

Source
Migration.scala
def reverse: Migration[B, A]

Returns the structural reverse of this migration.

Returns the structural reverse of this migration.

Note: Runtime execution of the reverse migration is best-effort. It may fail if information was lost during the forward migration.

Attributes

Source
Migration.scala
def size: Int

Returns the number of actions in this migration.

Returns the number of actions in this migration.

Attributes

Source
Migration.scala

Inherited methods

def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
Source
Product.scala
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product
Source
Product.scala