pub struct MigrationGraph { /* private fields */ }Expand description
A validated migration dependency graph with deterministic replay order.
Implementations§
Source§impl MigrationGraph
impl MigrationGraph
Sourcepub fn new(migrations: Vec<Migration>) -> Result<Self, MigrationError>
pub fn new(migrations: Vec<Migration>) -> Result<Self, MigrationError>
Validates migrations and computes their lexically deterministic topological order.
Sourcepub fn ordered(&self) -> impl Iterator<Item = &Migration>
pub fn ordered(&self) -> impl Iterator<Item = &Migration>
Returns migrations in deterministic dependency order.
Sourcepub fn app_heads(&self, app: &str) -> Vec<&Migration>
pub fn app_heads(&self, app: &str) -> Vec<&Migration>
Returns the terminal migrations for one application. Multiple heads indicate a branch that needs a merge migration before release.
Sourcepub fn plan_to(
&self,
applied: &BTreeSet<MigrationId>,
target: Option<&MigrationId>,
) -> Result<Vec<MigrationPlanStep>, MigrationError>
pub fn plan_to( &self, applied: &BTreeSet<MigrationId>, target: Option<&MigrationId>, ) -> Result<Vec<MigrationPlanStep>, MigrationError>
Builds and validates a forward-only plan. Independent applied migrations are retained. A target already passed in its app is rejected.
Sourcepub fn plan_forward(
&self,
applied: &BTreeSet<MigrationId>,
target: Option<&MigrationId>,
) -> Result<Vec<MigrationPlanStep>, MigrationError>
pub fn plan_forward( &self, applied: &BTreeSet<MigrationId>, target: Option<&MigrationId>, ) -> Result<Vec<MigrationPlanStep>, MigrationError>
Returns pending steps only, after checking graph and historical state.
pub fn validate_heads(&self) -> Result<(), MigrationError>
Sourcepub fn replay(
&self,
state: ProjectState,
) -> Result<ProjectState, MigrationError>
pub fn replay( &self, state: ProjectState, ) -> Result<ProjectState, MigrationError>
Replays every migration from an initial schema state.
Sourcepub fn replay_selected(
&self,
state: ProjectState,
selected: &BTreeSet<MigrationId>,
) -> Result<ProjectState, MigrationError>
pub fn replay_selected( &self, state: ProjectState, selected: &BTreeSet<MigrationId>, ) -> Result<ProjectState, MigrationError>
Replays a closed subset of migrations in graph order. Executors use this to reconstruct the state immediately before pending migrations.
Trait Implementations§
Source§impl Clone for MigrationGraph
impl Clone for MigrationGraph
Auto Trait Implementations§
impl Forget for MigrationGraph
impl Freeze for MigrationGraph
impl Move for MigrationGraph
impl RefUnwindSafe for MigrationGraph
impl Send for MigrationGraph
impl Sync for MigrationGraph
impl Unpin for MigrationGraph
impl UnsafeUnpin for MigrationGraph
impl UnwindSafe for MigrationGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more