pub trait Migration: Send + Sync {
// Required methods
fn version(&self) -> u32;
fn name(&self) -> &str;
fn up(&self, conn: &Connection) -> Result<()>;
// Provided methods
fn down(&self, _conn: &Connection) -> Result<()> { ... }
fn verify(&self, _conn: &Connection) -> Result<()> { ... }
}Expand description
Migration trait
Implement this to define a database migration.
Required Methods§
Sourcefn version(&self) -> u32
fn version(&self) -> u32
The version number this migration targets
Versions should be sequential starting from 2 (version 1 is the base schema).
Sourcefn up(&self, conn: &Connection) -> Result<()>
fn up(&self, conn: &Connection) -> Result<()>
Apply the migration (upgrade)
Provided Methods§
Sourcefn down(&self, _conn: &Connection) -> Result<()>
fn down(&self, _conn: &Connection) -> Result<()>
Rollback the migration (downgrade)
Optional - default implementation returns an error.
Sourcefn verify(&self, _conn: &Connection) -> Result<()>
fn verify(&self, _conn: &Connection) -> Result<()>
Optional: verify the migration was applied correctly