pub struct Migrator;Expand description
Migrator is used to handle running migration operations.
Implementations§
Source§impl Migrator
impl Migrator
Sourcepub async fn run(
db: &DbConn,
migrations: &mut Vec<Box<dyn MigratorTrait>>,
) -> Result<(), DbErr>
pub async fn run( db: &DbConn, migrations: &mut Vec<Box<dyn MigratorTrait>>, ) -> Result<(), DbErr>
run will run all of the database migrations provided via the migrations parameter. In microservice environments think about how this function is called. It contains an internal lock to prevent multiple clients running migrations at the same time but don’t rely on it!
use sea_migrations::Migrator;
use sea_orm::{ Database, DbErr };
#[tokio::main]
async fn main() -> Result<(), DbErr> {
let db = Database::connect("sqlite::memory:").await?;
Migrator::run(
&db,
&mut vec![
// Box::new(models::M20210101020202DoAThing),
],
)
.await
}
Auto Trait Implementations§
impl Freeze for Migrator
impl RefUnwindSafe for Migrator
impl Send for Migrator
impl Sync for Migrator
impl Unpin for Migrator
impl UnwindSafe for Migrator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more