pub struct MigrationManager { /* private fields */ }
Expand description
Main migration manager that handles all migration operations
Implementations§
Source§impl MigrationManager
impl MigrationManager
Sourcepub async fn new(config: Config) -> Result<Self, MigrationError>
pub async fn new(config: Config) -> Result<Self, MigrationError>
Create a new migration manager and establish database connection
Sourcepub async fn get_applied_migrations(
&self,
) -> Result<Vec<MigrationRecord>, MigrationError>
pub async fn get_applied_migrations( &self, ) -> Result<Vec<MigrationRecord>, MigrationError>
Get all applied migrations from the database
Sourcepub async fn get_migration_files(
&self,
) -> Result<Vec<MigrationFile>, MigrationError>
pub async fn get_migration_files( &self, ) -> Result<Vec<MigrationFile>, MigrationError>
Get all migration files from the filesystem
Sourcepub async fn get_pending_migrations(
&self,
) -> Result<Vec<MigrationFile>, MigrationError>
pub async fn get_pending_migrations( &self, ) -> Result<Vec<MigrationFile>, MigrationError>
Get pending migrations (files that haven’t been applied)
Sourcepub async fn apply_migration(
&mut self,
migration: &MigrationFile,
) -> Result<(), MigrationError>
pub async fn apply_migration( &mut self, migration: &MigrationFile, ) -> Result<(), MigrationError>
Apply a single migration
Sourcepub async fn rollback_migration(
&mut self,
version: &str,
) -> Result<(), MigrationError>
pub async fn rollback_migration( &mut self, version: &str, ) -> Result<(), MigrationError>
Rollback a single migration
Sourcepub async fn is_migration_applied(
&self,
version: &str,
) -> Result<bool, MigrationError>
pub async fn is_migration_applied( &self, version: &str, ) -> Result<bool, MigrationError>
Check if a migration is already applied
Sourcepub async fn verify_migrations(
&self,
) -> Result<Vec<MigrationError>, MigrationError>
pub async fn verify_migrations( &self, ) -> Result<Vec<MigrationError>, MigrationError>
Verify migration integrity (check checksums)
Sourcepub async fn reset_migrations(&mut self) -> Result<(), MigrationError>
pub async fn reset_migrations(&mut self) -> Result<(), MigrationError>
Reset all migrations (destructive operation)
Sourcepub fn get_config(&self) -> &Config
pub fn get_config(&self) -> &Config
Get the configuration
Sourcepub async fn update_migration_checksum(
&self,
version: &str,
new_checksum: &str,
) -> Result<(), MigrationError>
pub async fn update_migration_checksum( &self, version: &str, new_checksum: &str, ) -> Result<(), MigrationError>
Update the checksum of an existing migration record
Sourcepub async fn create_migration_file(
&self,
description: &str,
) -> Result<PathBuf, MigrationError>
pub async fn create_migration_file( &self, description: &str, ) -> Result<PathBuf, MigrationError>
Create a new migration file
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