Trait MigrationContext

Source
pub trait MigrationContext
where Self: MigrationSource<Ctx = Self> + Send + Sync + 'static,
{ type Exec: Executor; const HISTORY_TABLE: &str; // Required method fn executor(&mut self) -> &mut Self::Exec; // Provided methods fn apply<'migration, 'conn: 'migration, M>( &'conn mut self, migration: &'migration M, ) -> BoxFuture<'migration, TernResult<AppliedMigration>> where M: Migration<Ctx = Self> + Send + Sync + ?Sized { ... } fn latest_version(&mut self) -> BoxFuture<'_, TernResult<Option<i64>>> { ... } fn previously_applied( &mut self, ) -> BoxFuture<'_, TernResult<Vec<AppliedMigration>>> { ... } fn check_history_table(&mut self) -> BoxFuture<'_, TernResult<()>> { ... } fn drop_history_table(&mut self) -> BoxFuture<'_, TernResult<()>> { ... } fn insert_applied<'migration, 'conn: 'migration>( &'conn mut self, applied: &'migration AppliedMigration, ) -> BoxFuture<'migration, TernResult<()>> { ... } fn upsert_applied<'migration, 'conn: 'migration>( &'conn mut self, applied: &'migration AppliedMigration, ) -> BoxFuture<'migration, TernResult<()>> { ... } }
Expand description

The context in which a migration run occurs.

Required Associated Constants§

Source

const HISTORY_TABLE: &str

The name of the table in the database that tracks the history of this migration set.

It defaults to _tern_migrations in the default schema for the database driver if using the derive macro for this trait.

Required Associated Types§

Source

type Exec: Executor

The type for executing queries in a migration run.

Required Methods§

Source

fn executor(&mut self) -> &mut Self::Exec

A reference to the underlying Executor.

Provided Methods§

Source

fn apply<'migration, 'conn: 'migration, M>( &'conn mut self, migration: &'migration M, ) -> BoxFuture<'migration, TernResult<AppliedMigration>>
where M: Migration<Ctx = Self> + Send + Sync + ?Sized,

For a migration that is capable of building its query in this migration context, this builds the query, applies the migration, then updates the schema history table after.

Source

fn latest_version(&mut self) -> BoxFuture<'_, TernResult<Option<i64>>>

Gets the version of the most recently applied migration.

Source

fn previously_applied( &mut self, ) -> BoxFuture<'_, TernResult<Vec<AppliedMigration>>>

Get all previously applied migrations.

Source

fn check_history_table(&mut self) -> BoxFuture<'_, TernResult<()>>

Check that the history table exists and create it if not.

Source

fn drop_history_table(&mut self) -> BoxFuture<'_, TernResult<()>>

Drop the history table if requested.

Source

fn insert_applied<'migration, 'conn: 'migration>( &'conn mut self, applied: &'migration AppliedMigration, ) -> BoxFuture<'migration, TernResult<()>>

Insert an applied migration.

Source

fn upsert_applied<'migration, 'conn: 'migration>( &'conn mut self, applied: &'migration AppliedMigration, ) -> BoxFuture<'migration, TernResult<()>>

Upsert applied migrations.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§