pub trait MigrationStore {
// Required methods
fn init(&mut self) -> Result<(), Error>;
fn applied(&self) -> Result<Vec<MigrationRecord>, Error>;
fn mark_applied(&mut self, version: u64, name: &str) -> Result<(), Error>;
fn mark_rolled_back(&mut self, version: u64) -> Result<(), Error>;
// Provided methods
fn is_applied(&self, version: u64) -> Result<bool, Error> { ... }
fn current_version(&self) -> Result<u64, Error> { ... }
}Expand description
Storage backend for tracking applied migrations.
Implement this trait to store migration state in your preferred backend:
- SQLite, PostgreSQL, MySQL
- JSON/YAML file
- Redis, etcd
- In-memory (for testing)
The store is responsible for:
- Initializing any required schema/structure
- Recording when migrations are applied/rolled back
- Querying which migrations have been applied
Required Methods§
Sourcefn applied(&self) -> Result<Vec<MigrationRecord>, Error>
fn applied(&self) -> Result<Vec<MigrationRecord>, Error>
Get all applied migrations, sorted by version ascending
Provided Methods§
Sourcefn is_applied(&self, version: u64) -> Result<bool, Error>
fn is_applied(&self, version: u64) -> Result<bool, Error>
Check if a specific version has been applied
Sourcefn current_version(&self) -> Result<u64, Error>
fn current_version(&self) -> Result<u64, Error>
Get the highest applied version (0 if none)