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:
ensure_schema— idempotent schema bootstrap.load_applied— full applied-state read.record_applied— insert/replace one record.record_unapplied— remove one record (absent →Ok, matching Python delete semantics).
Method futures are returned as BoxFuture so the trait is object-safe
and can be used as Box<dyn MigrationStateStore>.
Required Methods§
Sourcefn ensure_schema(&self) -> BoxFuture<'_, Result<()>>
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(()).
Sourcefn load_applied(&self) -> BoxFuture<'_, Result<Vec<AppliedMigrationRecord>>>
fn load_applied(&self) -> BoxFuture<'_, Result<Vec<AppliedMigrationRecord>>>
Load all applied migration records in stable insertion order.
Sourcefn load_runs(&self) -> BoxFuture<'_, Result<Vec<MigrationRunRecord>>>
fn load_runs(&self) -> BoxFuture<'_, Result<Vec<MigrationRunRecord>>>
Load all migration execution run-log records.
Sourcefn record_applied(
&self,
record: AppliedMigrationRecord,
) -> BoxFuture<'_, Result<()>>
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.
Sourcefn record_unapplied<'a>(
&'a self,
app_label: &'a str,
name: &'a str,
) -> BoxFuture<'a, Result<()>>
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.
Sourcefn record_run(&self, record: MigrationRunRecord) -> BoxFuture<'_, Result<()>>
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".