(manager: &SchemaManager<'_>, mut steps: Option<u32>)
| 401 | } |
| 402 | |
| 403 | async fn exec_down<M>(manager: &SchemaManager<'_>, mut steps: Option<u32>) -> Result<(), DbErr> |
| 404 | where |
| 405 | M: MigratorTrait + ?Sized, |
| 406 | { |
| 407 | let db = manager.get_connection(); |
| 408 | |
| 409 | M::install(db).await?; |
| 410 | |
| 411 | if let Some(steps) = steps { |
| 412 | info!("Rolling back {} applied migrations", steps); |
| 413 | } else { |
| 414 | info!("Rolling back all applied migrations"); |
| 415 | } |
| 416 | |
| 417 | let migrations = M::get_applied_migrations(db).await?.into_iter().rev(); |
| 418 | if migrations.len() == 0 { |
| 419 | info!("No applied migrations"); |
| 420 | } |
| 421 | for Migration { migration, .. } in migrations { |
| 422 | if let Some(steps) = steps.as_mut() { |
| 423 | if steps == &0 { |
| 424 | break; |
| 425 | } |
| 426 | *steps -= 1; |
| 427 | } |
| 428 | info!("Rolling back migration '{}'", migration.name()); |
| 429 | migration.down(manager).await?; |
| 430 | info!("Migration '{}' has been rollbacked", migration.name()); |
| 431 | seaql_migrations::Entity::delete_many() |
| 432 | .filter(Expr::col(seaql_migrations::Column::Version).eq(migration.name())) |
| 433 | .table_name(M::migration_table_name()) |
| 434 | .exec(db) |
| 435 | .await?; |
| 436 | } |
| 437 | |
| 438 | Ok(()) |
| 439 | } |
| 440 | |
| 441 | async fn query_tables<C>(db: &C) -> SelectStatement |
| 442 | where |
nothing calls this directly
no test coverage detected