MigrationState in oxide_sql_core::migrations - Rust

Struct MigrationState 

Source

pub struct MigrationState { /* private fields */ }
Expand description

Tracks which migrations have been applied.

This struct provides an in-memory representation of the migration state. In a real application, you would load this from the database using the SQL constants provided in this module.

§Example

use oxide_sql_core::migrations::MigrationState;

let mut state = MigrationState::new();

// Check if a migration is applied
assert!(!state.is_applied("0001_initial"));

// Mark a migration as applied
state.mark_applied("0001_initial");
assert!(state.is_applied("0001_initial"));

// Mark a migration as unapplied (rolled back)
state.mark_unapplied("0001_initial");
assert!(!state.is_applied("0001_initial"));
Source§
Source

Creates a new empty migration state.

Source

Creates a migration state from a list of applied migration IDs.

This is useful for loading state from the database.

Source

Checks if a migration has been applied.

Source

Marks a migration as applied.

Source

Marks a migration as unapplied (rolled back).

Source

Returns an iterator over all applied migration IDs.

Source

Returns the number of applied migrations.

Source

Returns the SQL to create the migrations tracking table.

Source

Returns the SQL to insert a migration record.

Source

Returns the SQL to delete a migration record.

Source

Returns the SQL to check if a migration is applied.

Source

Returns the SQL to list all applied migrations.

§
§
§
§
§
§