pub trait Migration: Send + Sync {
type Ctx: MigrationContext;
// Required methods
fn migration_id(&self) -> MigrationId;
fn content(&self) -> String;
fn no_tx(&self) -> bool;
fn build<'a>(
&'a self,
ctx: &'a mut Self::Ctx,
) -> Pin<Box<dyn Future<Output = Result<Query, Error>> + Send + 'a>>;
// Provided methods
fn version(&self) -> i64 { ... }
fn to_applied(
&self,
duration_ms: i64,
applied_at: DateTime<Utc>,
content: &str,
) -> AppliedMigration { ... }
}
Expand description
A single migration in a migration set.
Required Associated Types§
Sourcetype Ctx: MigrationContext
type Ctx: MigrationContext
A migration context that is sufficient to build this migration.
Required Methods§
Sourcefn migration_id(&self) -> MigrationId
fn migration_id(&self) -> MigrationId
Get the MigrationId
for this migration.
Sourcefn content(&self) -> String
fn content(&self) -> String
The raw file content of the migration source file, or when stored as an applied migration in the history table, it is the query that was ran.
Provided Methods§
Sourcefn to_applied(
&self,
duration_ms: i64,
applied_at: DateTime<Utc>,
content: &str,
) -> AppliedMigration
fn to_applied( &self, duration_ms: i64, applied_at: DateTime<Utc>, content: &str, ) -> AppliedMigration
Convert this migration to an AppliedMigration
assuming that it was
successfully applied.