pub trait MigrationContext:
MigrationSource<Ctx = Self>
+ Send
+ Sync
+ 'static {
type Exec: Executor;
const HISTORY_TABLE: &'static str;
// Required method
fn executor(&mut self) -> &mut Self::Exec;
// Provided methods
fn apply<'migration, 'conn, M>(
&'conn mut self,
migration: &'migration M,
) -> Pin<Box<dyn Future<Output = Result<AppliedMigration, Error>> + Send + 'migration>>
where 'conn: 'migration,
M: Migration<Ctx = Self> + Send + Sync + ?Sized { ... }
fn latest_version(
&mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<i64>, Error>> + Send + '_>> { ... }
fn previously_applied(
&mut self,
) -> Pin<Box<dyn Future<Output = Result<Vec<AppliedMigration>, Error>> + Send + '_>> { ... }
fn check_history_table(
&mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>> { ... }
fn drop_history_table(
&mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>> { ... }
fn insert_applied<'migration, 'conn>(
&'conn mut self,
applied: &'migration AppliedMigration,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'migration>>
where 'conn: 'migration { ... }
fn upsert_applied<'migration, 'conn>(
&'conn mut self,
applied: &'migration AppliedMigration,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'migration>>
where 'conn: 'migration { ... }
}
Expand description
The context in which a migration run occurs.
Required Associated Constants§
Sourceconst HISTORY_TABLE: &'static str
const HISTORY_TABLE: &'static 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, M>(
&'conn mut self,
migration: &'migration M,
) -> Pin<Box<dyn Future<Output = Result<AppliedMigration, Error>> + Send + 'migration>>
fn apply<'migration, 'conn, M>( &'conn mut self, migration: &'migration M, ) -> Pin<Box<dyn Future<Output = Result<AppliedMigration, Error>> + Send + 'migration>>
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,
) -> Pin<Box<dyn Future<Output = Result<Option<i64>, Error>> + Send + '_>>
fn latest_version( &mut self, ) -> Pin<Box<dyn Future<Output = Result<Option<i64>, Error>> + Send + '_>>
Gets the version of the most recently applied migration.
Sourcefn previously_applied(
&mut self,
) -> Pin<Box<dyn Future<Output = Result<Vec<AppliedMigration>, Error>> + Send + '_>>
fn previously_applied( &mut self, ) -> Pin<Box<dyn Future<Output = Result<Vec<AppliedMigration>, Error>> + Send + '_>>
Get all previously applied migrations.
Sourcefn check_history_table(
&mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>
fn check_history_table( &mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>
Check that the history table exists and create it if not.
Sourcefn drop_history_table(
&mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>
fn drop_history_table( &mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>
Drop the history table if requested.
Sourcefn insert_applied<'migration, 'conn>(
&'conn mut self,
applied: &'migration AppliedMigration,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'migration>>where
'conn: 'migration,
fn insert_applied<'migration, 'conn>(
&'conn mut self,
applied: &'migration AppliedMigration,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'migration>>where
'conn: 'migration,
Insert an applied migration.
Sourcefn upsert_applied<'migration, 'conn>(
&'conn mut self,
applied: &'migration AppliedMigration,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'migration>>where
'conn: 'migration,
fn upsert_applied<'migration, 'conn>(
&'conn mut self,
applied: &'migration AppliedMigration,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'migration>>where
'conn: 'migration,
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.