Skip to main content

invert

Function invert 

Source
pub fn invert(
    forward: &[Operation],
    prev: &SchemaSnapshot,
) -> Result<Vec<Operation>, MigrateError>
Expand description

Compute the rollback form of a forward operation list.

Walks forward in reverse — the last op applied is the first op rolled back. prev is the schema state before the migration was applied (i.e. the predecessor migration’s snapshot, or empty for the very first migration).

§Errors

Returns MigrateError::Validation if:

  • Any data op has reversible: false (cannot be rolled back).
  • A data op has reversible: true but no reverse_sql (corrupt — file::load should already have rejected this).
  • A DropTable/DropColumn references something missing from prev, meaning the predecessor snapshot was tampered with.