pub trait Migration<Ctx>: Send + Sync {
// Required methods
fn version(&self) -> u64;
fn name(&self) -> &str;
fn apply(&self, ctx: &mut Ctx) -> Result<(), Error>;
// Provided methods
fn phase(&self) -> Phase { ... }
fn rollback(&self, ctx: &mut Ctx) -> Result<(), Error> { ... }
fn can_rollback(&self) -> bool { ... }
}Expand description
A migration that can be applied or rolled back.
Migrations are versioned changes to your system. Each migration has:
- A unique version number (must be sequential starting from 1)
- A human-readable name
- A deployment phase (pre-deploy or post-deploy)
- An apply action
- An optional rollback action
The generic type Ctx is the context passed to apply/rollback functions.
This could be a database connection, file system handle, API client, etc.
Required Methods§
Provided Methods§
Sourcefn can_rollback(&self) -> bool
fn can_rollback(&self) -> bool
Whether this migration supports rollback