pub struct Engine { /* private fields */ }Expand description
Main engine for schema synchronization
The engine coordinates all components to provide schema sync functionality. It’s designed to be used by the CLI layer, which handles mode-specific behavior (dry-run, validation, etc.).
Implementations§
Source§impl Engine
impl Engine
Sourcepub fn new(
inspector: Box<dyn SchemaInspector>,
runner: Box<dyn MigrationRunner>,
planner: Box<dyn Planner>,
executor: Box<dyn Executor>,
diff_calculator: Box<dyn DiffCalculator>,
snapshot_store: Option<Box<dyn SnapshotStore>>,
) -> Self
pub fn new( inspector: Box<dyn SchemaInspector>, runner: Box<dyn MigrationRunner>, planner: Box<dyn Planner>, executor: Box<dyn Executor>, diff_calculator: Box<dyn DiffCalculator>, snapshot_store: Option<Box<dyn SnapshotStore>>, ) -> Self
Create a new engine
§Arguments
inspector- Schema inspector for reading current schemarunner- Migration runner for executing changesplanner- Planner for creating migration plansexecutor- Executor for orchestrating executiondiff_calculator- Calculator for computing diffssnapshot_store- Optional snapshot store for versioning
Sourcepub fn from_adapter(
adapter: Box<dyn DatabaseAdapter>,
planner: Box<dyn Planner>,
executor: Box<dyn Executor>,
diff_calculator: Box<dyn DiffCalculator>,
snapshot_store: Option<Box<dyn SnapshotStore>>,
) -> Self
pub fn from_adapter( adapter: Box<dyn DatabaseAdapter>, planner: Box<dyn Planner>, executor: Box<dyn Executor>, diff_calculator: Box<dyn DiffCalculator>, snapshot_store: Option<Box<dyn SnapshotStore>>, ) -> Self
Create an engine from a database adapter
This is a convenience method that creates an engine with default implementations of planner, executor, and diff calculator.
Sourcepub async fn sync_tenant(
&self,
tenant: &TenantContext,
target: Option<&SchemaSnapshot>,
execute: bool,
) -> Result<SyncResult>
pub async fn sync_tenant( &self, tenant: &TenantContext, target: Option<&SchemaSnapshot>, execute: bool, ) -> Result<SyncResult>
Sync a tenant’s schema to match a target snapshot
This is the main operation. It:
- Inspects the current schema
- Calculates the diff to the target
- Creates a migration plan
- Optionally executes the plan
§Arguments
tenant- The tenant contexttarget- Target schema snapshot (or None to use stored snapshot)execute- Whether to actually execute the migration (false for dry-run)
§Returns
Sync result with diff and execution details.
Sourcepub async fn inspect_tenant(
&self,
tenant: &TenantContext,
) -> Result<SchemaSnapshot>
pub async fn inspect_tenant( &self, tenant: &TenantContext, ) -> Result<SchemaSnapshot>
Get the current schema snapshot for a tenant
Sourcepub fn calculate_diff(
&self,
from: &SchemaSnapshot,
to: &SchemaSnapshot,
) -> SchemaDiff
pub fn calculate_diff( &self, from: &SchemaSnapshot, to: &SchemaSnapshot, ) -> SchemaDiff
Calculate diff between two snapshots
Sourcepub async fn list_tenants(&self) -> Result<Vec<TenantContext>>
pub async fn list_tenants(&self) -> Result<Vec<TenantContext>>
List all tenants
Auto Trait Implementations§
impl !RefUnwindSafe for Engine
impl !UnwindSafe for Engine
impl Freeze for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl UnsafeUnpin for Engine
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