Skip to main content

Migration

Trait Migration 

Source
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§

Source

fn from_version(&self) -> &VersionReq

Version requirement that the current stored schema must satisfy.

Source

fn to_version(&self) -> &Version

Version that this migration produces.

Source

fn name(&self) -> &str

Short stable identifier, e.g. "plan_assignments_sidecar_to_native".

Source

fn describe(&self) -> &str

Human-readable one-liner for dry-run output.

Source

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).

Source

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".

Implementors§