pub struct MigrationRunner { /* private fields */ }Expand description
Migration runner for applying and tracking database migrations
Implementations§
Source§impl MigrationRunner
impl MigrationRunner
Sourcepub fn new(pool: DatabasePool) -> Self
pub fn new(pool: DatabasePool) -> Self
Create a new migration runner
Sourcepub async fn initialize(&self) -> Result<()>
pub async fn initialize(&self) -> Result<()>
Initialize the migrations tracking table
Creates the schema_migrations table if it doesn’t exist.
Sourcepub fn get_builtin_migrations() -> Vec<Migration>
pub fn get_builtin_migrations() -> Vec<Migration>
Get all built-in migrations
Returns the standard set of migrations for oxify-storage.
Sourcepub async fn is_applied(&self, version: &str) -> Result<bool>
pub async fn is_applied(&self, version: &str) -> Result<bool>
Check if a migration has been applied
Sourcepub async fn apply_migration(&self, migration: &Migration) -> Result<i64>
pub async fn apply_migration(&self, migration: &Migration) -> Result<i64>
Apply a single migration
Runs the migration in a transaction and records it in the migrations table.
Sourcepub async fn run_pending_migrations(&self) -> Result<Vec<String>>
pub async fn run_pending_migrations(&self) -> Result<Vec<String>>
Run all pending migrations
Applies all migrations that haven’t been applied yet.
Sourcepub async fn get_migration_status(&self) -> Result<Vec<MigrationStatus>>
pub async fn get_migration_status(&self) -> Result<Vec<MigrationStatus>>
Get migration status for all migrations
Sourcepub async fn rollback_migration(&self, version: &str) -> Result<()>
pub async fn rollback_migration(&self, version: &str) -> Result<()>
Rollback a migration
Reverts a migration if it has a down_sql defined.
Sourcepub async fn verify_checksums(&self) -> Result<Vec<String>>
pub async fn verify_checksums(&self) -> Result<Vec<String>>
Verify migration checksums match recorded values
Detects if migration files have been modified after being applied.
Auto Trait Implementations§
impl Freeze for MigrationRunner
impl !RefUnwindSafe for MigrationRunner
impl Send for MigrationRunner
impl Sync for MigrationRunner
impl Unpin for MigrationRunner
impl !UnwindSafe for MigrationRunner
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