Skip to main content

Migrator

Struct Migrator 

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

Source

pub fn new() -> Migrator<X>

Source

pub fn add(self, m: impl Migration<X> + 'static) -> Migrator<X>

Append a step (any Migration impl).

Source

pub fn create_table<E>(self, name: &'static str) -> Migrator<X>
where E: Entity + 'static,

Append a “create E’s table” step.

Source

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.

Source

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.

Source

pub async fn run_on_each(&self, dbs: &[&X]) -> Result<(), Error>

run against each executor in turn — the shard fan-out (every shard gets the same schema, tracked independently).

Trait Implementations§

Source§

impl<X> Default for Migrator<X>
where X: Executor,

Source§

fn default() -> Migrator<X>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<X> !RefUnwindSafe for Migrator<X>

§

impl<X> !Send for Migrator<X>

§

impl<X> !Sync for Migrator<X>

§

impl<X> !UnwindSafe for Migrator<X>

§

impl<X> Freeze for Migrator<X>

§

impl<X> Unpin for Migrator<X>

§

impl<X> UnsafeUnpin for Migrator<X>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more