MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / exec_down

Function exec_down

sea-orm-migration/src/migrator.rs:403–439  ·  view source on GitHub ↗
(manager: &SchemaManager<'_>, mut steps: Option<u32>)

Source from the content-addressed store, hash-verified

401}
402
403async fn exec_down<M>(manager: &SchemaManager<'_>, mut steps: Option<u32>) -> Result<(), DbErr>
404where
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
441async fn query_tables<C>(db: &C) -> SelectStatement
442where

Callers

nothing calls this directly

Calls 10

delete_manyFunction · 0.85
revMethod · 0.80
into_iterMethod · 0.80
filterMethod · 0.80
get_connectionMethod · 0.45
downMethod · 0.45
execMethod · 0.45
table_nameMethod · 0.45
eqMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected