pub trait Migration: Send + Sync {
// Required methods
fn from_version(&self) -> &VersionReq;
fn to_version(&self) -> &Version;
fn name(&self) -> &str;
fn describe(&self) -> &str;
fn applies_to(
&self,
repo: &Repository,
ref_name: &str,
) -> Result<bool, MigrateError>;
fn migrate(
&self,
repo: &Repository,
ref_name: &str,
) -> Result<MigrationOutcome, MigrateError>;
}Expand description
A single named, idempotent migration step.
Required Methods§
Sourcefn from_version(&self) -> &VersionReq
fn from_version(&self) -> &VersionReq
Version requirement that the current stored schema must satisfy.
Sourcefn to_version(&self) -> &Version
fn to_version(&self) -> &Version
Version that this migration produces.
Sourcefn applies_to(
&self,
repo: &Repository,
ref_name: &str,
) -> Result<bool, MigrateError>
fn applies_to( &self, repo: &Repository, ref_name: &str, ) -> Result<bool, MigrateError>
Cheap probe: is there actually work to do on ref_name?
Returning Ok(false) makes the migration a no-op (still advances
the schema_version sentinel, but without changing user data).
Sourcefn migrate(
&self,
repo: &Repository,
ref_name: &str,
) -> Result<MigrationOutcome, MigrateError>
fn migrate( &self, repo: &Repository, ref_name: &str, ) -> Result<MigrationOutcome, MigrateError>
Perform the migration, producing (or skipping) one commit tagged
IntentCategory::Migrate that also bumps /_meta/schema_version
to self.to_version().
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".