pub struct Migrator<X> { /* private fields */ }Expand description
An ordered, idempotent set of migrations for one executor type X.
Implementations§
Source§impl<X> Migrator<X>where
X: Executor,
impl<X> Migrator<X>where
X: Executor,
pub fn new() -> Migrator<X>
Sourcepub fn add(self, m: impl Migration<X> + 'static) -> Migrator<X>
pub fn add(self, m: impl Migration<X> + 'static) -> Migrator<X>
Append a step (any Migration impl).
Sourcepub fn create_table<E>(self, name: &'static str) -> Migrator<X>where
E: Entity + 'static,
pub fn create_table<E>(self, name: &'static str) -> Migrator<X>where
E: Entity + 'static,
Append a “create E’s table” step.
Sourcepub fn names(&self) -> Vec<&'static str>
pub fn names(&self) -> Vec<&'static str>
The names of every step, in registration order — what a
migration-runner port reports as defined(), and the source of
the migration “head” used to dedupe boot-time runs.
The port that reports it is defined by the consumer, not here.
Sourcepub async fn run(&self, db: &X) -> Result<Vec<&'static str>, Error>
pub async fn run(&self, db: &X) -> Result<Vec<&'static str>, Error>
Apply every not-yet-applied step to db, recording each in
_orm_migrations. Idempotent: re-running applies only new steps.
Returns the names applied this run.
When db reports it is sharded (Executor::is_sharded),
the sharding control tables (shards, shard_directory) are ensured on
its global database first — the ORM owns that metadata, so no flavor
declares it. A no-op on a single, unsharded database.