Skip to main content

rollback_last

Function rollback_last 

Source
pub async fn rollback_last(
    pool: &DbPool,
    dir: &str,
) -> Result<Option<String>, DbError>
Available on crate features model-mysql or model-postgres or model-sqlite only.
Expand description

Roll back the most recently applied migration in dir. Called by DbPool::rollback_last.

Requires a companion <version-stem>.down.sql file next to the up migration it undoes; returns Err if that file is missing. Runs the down file’s statements and deletes the _schema_migrations row inside one transaction — rolled back together on failure, same as run_migrations.

Returns Ok(None) if no migrations are currently applied.