Skip to main content

MigrationStateStore

Trait MigrationStateStore 

Source
pub trait MigrationStateStore: Send + Sync {
    // Required methods
    fn ensure_schema(&self) -> BoxFuture<'_, Result<()>>;
    fn load_applied(&self) -> BoxFuture<'_, Result<Vec<AppliedMigrationRecord>>>;
    fn load_runs(&self) -> BoxFuture<'_, Result<Vec<MigrationRunRecord>>>;
    fn record_applied(
        &self,
        record: AppliedMigrationRecord,
    ) -> BoxFuture<'_, Result<()>>;
    fn record_unapplied<'a>(
        &'a self,
        app_label: &'a str,
        name: &'a str,
    ) -> BoxFuture<'a, Result<()>>;
    fn record_run(
        &self,
        record: MigrationRunRecord,
    ) -> BoxFuture<'_, Result<()>>;
}
Expand description

Seam trait for migration applied-state storage.

Implementations must be Send + Sync and expose four operations that map 1-to-1 to the existing Python MigrationStateManager surface:

Method futures are returned as BoxFuture so the trait is object-safe and can be used as Box<dyn MigrationStateStore>.

Required Methods§

Source

fn ensure_schema(&self) -> BoxFuture<'_, Result<()>>

Ensure the state-storage schema exists, creating it if absent.

This is idempotent: calling it on an already-initialised store is a no-op Ok(()).

Source

fn load_applied(&self) -> BoxFuture<'_, Result<Vec<AppliedMigrationRecord>>>

Load all applied migration records in stable insertion order.

Source

fn load_runs(&self) -> BoxFuture<'_, Result<Vec<MigrationRunRecord>>>

Load all migration execution run-log records.

Source

fn record_applied( &self, record: AppliedMigrationRecord, ) -> BoxFuture<'_, Result<()>>

Record a migration as applied, inserting or replacing by (app_label, name) identity.

Calling this twice with the same identity is idempotent: the second call replaces the first; no duplicates are stored.

Source

fn record_unapplied<'a>( &'a self, app_label: &'a str, name: &'a str, ) -> BoxFuture<'a, Result<()>>

Remove the applied record identified by (app_label, name).

If no such record exists the call succeeds silently, matching the Python record_unapplied delete-absent no-op.

Source

fn record_run(&self, record: MigrationRunRecord) -> BoxFuture<'_, Result<()>>

Insert or replace one migration execution run-log record by run_id.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§