pub trait MigrationContext{
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§
Sourceconst HISTORY_TABLE: &str
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§
Required Methods§
Provided Methods§
Sourcefn apply<'migration, 'conn: 'migration, M>(
&'conn mut self,
migration: &'migration M,
) -> BoxFuture<'migration, TernResult<AppliedMigration>>
fn apply<'migration, 'conn: 'migration, M>( &'conn mut self, migration: &'migration M, ) -> BoxFuture<'migration, TernResult<AppliedMigration>>
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.
Sourcefn latest_version(&mut self) -> BoxFuture<'_, TernResult<Option<i64>>>
fn latest_version(&mut self) -> BoxFuture<'_, TernResult<Option<i64>>>
Gets the version of the most recently applied migration.
Sourcefn previously_applied(
&mut self,
) -> BoxFuture<'_, TernResult<Vec<AppliedMigration>>>
fn previously_applied( &mut self, ) -> BoxFuture<'_, TernResult<Vec<AppliedMigration>>>
Get all previously applied migrations.
Sourcefn check_history_table(&mut self) -> BoxFuture<'_, TernResult<()>>
fn check_history_table(&mut self) -> BoxFuture<'_, TernResult<()>>
Check that the history table exists and create it if not.
Sourcefn drop_history_table(&mut self) -> BoxFuture<'_, TernResult<()>>
fn drop_history_table(&mut self) -> BoxFuture<'_, TernResult<()>>
Drop the history table if requested.
Sourcefn insert_applied<'migration, 'conn: 'migration>(
&'conn mut self,
applied: &'migration AppliedMigration,
) -> BoxFuture<'migration, TernResult<()>>
fn insert_applied<'migration, 'conn: 'migration>( &'conn mut self, applied: &'migration AppliedMigration, ) -> BoxFuture<'migration, TernResult<()>>
Insert an applied migration.
Sourcefn upsert_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<()>>
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.