Skip to main content

Migrates

Trait Migrates 

Source
pub trait Migrates: RelationalBackend {
    // Required methods
    fn migrate(
        &self,
        migrations: &[Migration],
    ) -> impl Future<Output = Result<MigrateReport, MigrateError>> + Send;
    fn applied_versions(
        &self,
    ) -> impl Future<Output = Result<Vec<i64>, MigrateError>> + Send;
}
Expand description

A relational backend that keeps a migration ledger.

The ledger lives in the connection’s current schema (or database): point this at a database a program owns, never at one whose ledger belongs to something else.

Required Methods§

Source

fn migrate( &self, migrations: &[Migration], ) -> impl Future<Output = Result<MigrateReport, MigrateError>> + Send

Apply migrations in version order, skipping those already applied. Each migration runs in its own transaction where the database can; refuses (applying nothing further) if an applied migration’s text has changed, if the database has applied a version the program does not know, or if a migration is recorded as dirty.

Source

fn applied_versions( &self, ) -> impl Future<Output = Result<Vec<i64>, MigrateError>> + Send

The versions the ledger says succeeded, ascending; empty if there is no ledger yet.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Migrates for PgBackend

Source§

impl<R> Migrates for Defective<'_, R>

The known-bad migrator: no ledger, no checksum, no transaction. It runs each migration’s statements (split on ;) straight on the wrapped backend every time it is asked.