Migration constructor

Migration(
  1. Operation forward, {
  2. dynamic reverse,
})

Construct a migration from its constituent forward Operation and optionally reverse.

For use in scenarios where the database may be downgraded, reverse is the operation that "undoes" the forward operation. It not always necessary or possible for the forward and reverse operations to be true inverses. Instead, the reverse should restore the database back to a suitable state such that A) prior versions of code that do not expect this operation may operate and B) the upgrade can be reapplied as expected.

The default reverse operation is noop.

Implementation

Migration(this.forward, {reverse})
    : this.reverse = reverse ?? Operation<void>(noop);