SchemaMigration class

A Migration described as a list of ColumnOperations instead of hand-written map surgery.

SchemaMigration(
  fromVersion: 1,
  toVersion: 2,
  operations: [
    ColumnOperation.add('priority', defaultValue: 0),
    ColumnOperation.rename('title', to: 'name'),
  ],
)

Rows can be scoped with entityType (matched against the row's __typename) or an arbitrary where predicate; rows that don't match pass through untouched. Unlike a hand-written Migration.migrate, migrate never mutates its input map — matched rows are copied before operations run, which keeps the executor's rollback snapshot intact even for adapters that hand out live map references.

Inheritance

Constructors

SchemaMigration({required int fromVersion, required int toVersion, required List<ColumnOperation> operations, String? entityType, bool where(Map<String, dynamic> row)?, String? sqlWhere})

Properties

entityType String?
When set, only rows whose __typename equals this value are migrated.
final
fromVersion int
The schema version this migration starts from.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
operations List<ColumnOperation>
The operations applied, in order, to every matching row.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sqlWhere String?
SQL WHERE clause (without the keyword) scoping the UPDATE statements generated for the SQL migration path — the SQL counterpart of where. Ignored by the map-based path.
final
toVersion int
The schema version this migration migrates to.
no setteroverride
where bool Function(Map<String, dynamic> row)?
When set, only rows for which this predicate returns true are migrated. Combined with entityType when both are given.
final

Methods

migrate(Map<String, dynamic> oldData) Map<String, dynamic>
Executes the migration logic on a single raw data object. The map represents a single entity serialized to a map.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited