pub struct MigrationManager { /* private fields */ }Expand description
Migration manager for creating and loading migrations
Implementations§
Source§impl MigrationManager
impl MigrationManager
Sourcepub fn with_config(config: MigrationConfig) -> Self
pub fn with_config(config: MigrationConfig) -> Self
Create a new migration manager with custom configuration
Sourcepub fn config(&self) -> &MigrationConfig
pub fn config(&self) -> &MigrationConfig
Get the configuration
Sourcepub async fn create_migration(&self, name: &str) -> OrmResult<String>
pub async fn create_migration(&self, name: &str) -> OrmResult<String>
Create a new migration file
Sourcepub async fn load_migrations(&self) -> OrmResult<Vec<Migration>>
pub async fn load_migrations(&self) -> OrmResult<Vec<Migration>>
Load all migration files from the migrations directory
Sourcepub fn split_sql_statements(&self, sql: &str) -> OrmResult<Vec<String>>
pub fn split_sql_statements(&self, sql: &str) -> OrmResult<Vec<String>>
Split SQL statements for execution using proper SQL parsing
Sourcepub fn create_migrations_table_sql(&self) -> String
pub fn create_migrations_table_sql(&self) -> String
SQL to create the migrations tracking table
Sourcepub fn check_migration_sql(&self, migration_id: &str) -> (String, Vec<String>)
pub fn check_migration_sql(&self, migration_id: &str) -> (String, Vec<String>)
SQL to check if a migration has been applied
Sourcepub fn record_migration_sql(
&self,
migration_id: &str,
batch: i32,
) -> (String, Vec<String>)
pub fn record_migration_sql( &self, migration_id: &str, batch: i32, ) -> (String, Vec<String>)
SQL to record a migration as applied
Sourcepub fn remove_migration_sql(&self, migration_id: &str) -> (String, Vec<String>)
pub fn remove_migration_sql(&self, migration_id: &str) -> (String, Vec<String>)
SQL to remove a migration record (for rollback)
Sourcepub fn get_latest_batch_sql(&self) -> String
pub fn get_latest_batch_sql(&self) -> String
SQL to get the latest batch number
Sourcepub fn get_applied_migrations_sql(&self) -> String
pub fn get_applied_migrations_sql(&self) -> String
SQL to get applied migrations
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MigrationManager
impl RefUnwindSafe for MigrationManager
impl Send for MigrationManager
impl Sync for MigrationManager
impl Unpin for MigrationManager
impl UnwindSafe for MigrationManager
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
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