pub struct TableSchemaSnapshot {
pub version: u8,
pub name: String,
pub primary_key: String,
pub alignment: u32,
pub columns: Vec<ColumnSnapshot>,
pub indexes: Vec<IndexSnapshot>,
}Expand description
Frozen, comparable view of a TableSchema used for migration detection.
A snapshot captures the structural shape of a table at a point in time so that two versions can be diffed to derive the migration steps required to bring the on-disk representation up to date with the current schema definition.
Fields§
§version: u8Version tag of the snapshot binary layout, see
SCHEMA_SNAPSHOT_VERSION.
name: StringName of the table this snapshot was taken from.
primary_key: StringName of the column declared as primary key.
alignment: u32Record alignment, in bytes, used for on-disk layout.
columns: Vec<ColumnSnapshot>Snapshots of every column in declaration order.
indexes: Vec<IndexSnapshot>Snapshots of every secondary index defined on the table.
Implementations§
Source§impl TableSchemaSnapshot
impl TableSchemaSnapshot
Sourcepub fn latest_version() -> u8
pub fn latest_version() -> u8
Returns the latest version of the snapshot format.
Sourcepub fn validate_encoding(&self) -> MemoryResult<()>
pub fn validate_encoding(&self) -> MemoryResult<()>
Checks that every name, count and nested payload fits its on-disk
field, so the snapshot round-trips exactly through Encode.
Table, primary key, column, foreign key, custom type and index column names, and the number of columns of each index, are limited to 255 bytes or entries. Column and index counts, each encoded column, index and default value, and the whole snapshot are limited to 65 535 bytes or entries.
Must be called before the snapshot is persisted: Encode::encode
cannot report an error and its output is unspecified for a snapshot
that fails this check.
§Errors
Returns MemoryError::ConstraintViolation naming the first field
that exceeds its limit.