pub struct MigrationRegistry { /* private fields */ }Expand description
Names → forward (and optional backwards) functions.
Implementations§
Source§impl MigrationRegistry
impl MigrationRegistry
Sourcepub fn register(
&mut self,
name: impl Into<String>,
f: impl Fn(Db) -> RustFuture + Send + Sync + 'static,
)
pub fn register( &mut self, name: impl Into<String>, f: impl Fn(Db) -> RustFuture + Send + Sync + 'static, )
Register name. The same map is used for forwards and backwards;
a reversible RunRust stores both names as separate entries.
Args: name: Operation identifier in the migration file. f: Callback whose future owns completion of its work.
Returns: None after registering with ordinary, conservative retry policy.
Unconfirmed non-transactional execution blocks automatic retry.
Use register_replay_safe only with an established idempotence contract.
Sourcepub fn register_replay_safe(
&mut self,
name: impl Into<String>,
f: impl Fn(Db) -> RustFuture + Send + Sync + 'static,
)
pub fn register_replay_safe( &mut self, name: impl Into<String>, f: impl Fn(Db) -> RustFuture + Send + Sync + 'static, )
Register a callback whose committed effects can safely be repeated.
Args: name: Operation name used by the migration file. f: Callback safe to retry after interruption at any await point.
Returns: None after registering the callback and its explicit retry policy.
Use only after establishing idempotence for database and external
effects. Registration permits retry; it does not verify idempotence.
Ordinary register clears this declaration when replacing a name.
Sourcepub async fn run(&self, name: &str, db: &Db) -> Result<(), MigrationError>
pub async fn run(&self, name: &str, db: &Db) -> Result<(), MigrationError>
Run the function named name.
On SQLite the function runs on the schema-change connection with
PRAGMA foreign_keys off (see the migrations guide), so data code
must stay FK-clean by hand; orphans fail the migration at commit.
§Errors
MigrationError::UnregisteredRust or the function’s own error.
Trait Implementations§
Source§impl Clone for MigrationRegistry
impl Clone for MigrationRegistry
Source§fn clone(&self) -> MigrationRegistry
fn clone(&self) -> MigrationRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more