Struct sqlx::migrate::Migrator [−][src]
Fields
migrations: Cow<'static, [Migration]>
ignore_missing: bool
Implementations
pub async fn new<'s, S>(source: S) -> Result<Migrator, MigrateError> where
S: MigrationSource<'s>,
pub async fn new<'s, S>(source: S) -> Result<Migrator, MigrateError> where
S: MigrationSource<'s>,
Creates a new instance with the given source.
Examples
use std::path::Path;
// Read migrations from a local folder: ./migrations
let m = Migrator::new(Path::new("./migrations")).await?;
See MigrationSource for details on structure of the ./migrations
directory.
Specify should ignore applied migrations that missing in the resolved migrations.
Run any pending migrations against the database; and, validate previously applied migrations against the current migration source to detect accidental changes in previously-applied migrations.
Examples
let m = Migrator::new(std::path::Path::new("./migrations")).await?;
let pool = sqlx_core::sqlite::SqlitePoolOptions::new().connect("sqlite::memory:").await?;
m.run(&pool).await