pub struct SchemaSync { /* private fields */ }Expand description
Schema Sync 协调器
Implementations§
Source§impl SchemaSync
impl SchemaSync
Sourcepub fn with_generator(
entity_tables: Vec<TableDef>,
ddl_generator: Box<dyn DdlGenerator>,
) -> Self
pub fn with_generator( entity_tables: Vec<TableDef>, ddl_generator: Box<dyn DdlGenerator>, ) -> Self
创建 SchemaSync(指定 DDL 生成器)
Sourcepub fn with_rename_threshold(self, max_distance: usize, max_ratio: f64) -> Self
pub fn with_rename_threshold(self, max_distance: usize, max_ratio: f64) -> Self
配置重命名检测阈值(v2.2.0 B-2)
Sourcepub async fn sync_dry_run(
&self,
conn: &mut dyn Connection,
) -> Result<Vec<String>, DbError>
pub async fn sync_dry_run( &self, conn: &mut dyn Connection, ) -> Result<Vec<String>, DbError>
干运行:计算 DDL 但不执行
- introspect → 读取 DB 现有表结构
- diff → 计算变更
- 检查破坏性变更 → 若有则返回
Err(DestructiveChangeDetected) - generate → 生成 DDL
Sourcepub async fn sync(
&self,
conn: &mut dyn Connection,
) -> Result<SyncResult, DbError>
pub async fn sync( &self, conn: &mut dyn Connection, ) -> Result<SyncResult, DbError>
执行同步:事务内执行 DDL
- sync_dry_run → 获取 DDL
- begin_transaction
- 逐条执行 DDL
- commit / rollback
Sourcepub fn diff_against(&self, db_tables: &[TableDef]) -> SchemaDiff
pub fn diff_against(&self, db_tables: &[TableDef]) -> SchemaDiff
仅计算 diff(不连接 DB)
Sourcepub async fn destructive_sync(
&self,
conn: &mut dyn Connection,
confirm: Confirm,
hooks: Option<&dyn DataMigrationHook>,
) -> Result<DestructiveSyncResult, DbError>
pub async fn destructive_sync( &self, conn: &mut dyn Connection, confirm: Confirm, hooks: Option<&dyn DataMigrationHook>, ) -> Result<DestructiveSyncResult, DbError>
Auto Trait Implementations§
impl !RefUnwindSafe for SchemaSync
impl !UnwindSafe for SchemaSync
impl Freeze for SchemaSync
impl Send for SchemaSync
impl Sync for SchemaSync
impl Unpin for SchemaSync
impl UnsafeUnpin for SchemaSync
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more