pub struct Migration {
pub id: String,
pub app: Option<String>,
pub dependencies: Vec<String>,
pub operations: Vec<Operation>,
pub atomic: bool,
pub replaces: Vec<String>,
pub checksum: String,
}Expand description
On-disk (and in-memory) migration.
id is a zero-padded sequence plus a slug (0001_initial). checksum is
a 16-digit hex FNV-1a of the canonical JSON of id, dependencies,
operations, atomic and replaces (the checksum field itself is excluded).
Fields§
§id: String0001_initial.
app: Option<String>Optional app label. Single-app projects leave this unset.
dependencies: Vec<String>Ids of migrations that must be applied first.
operations: Vec<Operation>Ordered operations.
atomic: boolWrap execution in a transaction when the backend supports it.
No effect on SQLite: the whole migrate/rollback run is already
one transaction there (the lock), so a run is all-or-nothing. MySQL
never wraps DDL regardless of this flag.
replaces: Vec<String>Ids this squash replaces. The loader treats this migration as applied when every replaced id is in the history table.
checksum: StringContent checksum (see module docs).
Implementations§
Source§impl Migration
impl Migration
Sourcepub fn new(
id: impl Into<String>,
dependencies: Vec<String>,
operations: Vec<Operation>,
atomic: bool,
replaces: Vec<String>,
) -> Result<Self, MigrationError>
pub fn new( id: impl Into<String>, dependencies: Vec<String>, operations: Vec<Operation>, atomic: bool, replaces: Vec<String>, ) -> Result<Self, MigrationError>
Build a migration and fill in its checksum.
§Errors
JSON encoding of the checksum body (does not fail for these types).
Sourcepub fn compute_checksum(&self) -> Result<String, MigrationError>
pub fn compute_checksum(&self) -> Result<String, MigrationError>
Sourcepub fn refresh_checksum(&mut self) -> Result<(), MigrationError>
pub fn refresh_checksum(&mut self) -> Result<(), MigrationError>
Sourcepub fn is_irreversible(&self) -> bool
pub fn is_irreversible(&self) -> bool
Whether any operation is unconditionally irreversible.