Skip to main content

Crate crdt_migrate

Crate crdt_migrate 

Source
Expand description

§crdt-migrate

Transparent schema migrations for crdt-kit.

When your data schema evolves between versions, crdt-migrate ensures that persisted data is automatically and transparently migrated — no downtime, no manual intervention, no data loss.

§How It Works

  1. Every serialized CRDT is wrapped in a version envelope (3-byte header).
  2. When data is loaded, the envelope version is compared to the current version.
  3. If they differ, a chain of migration steps runs automatically.
  4. Optionally, the migrated data is written back to storage.

§Key Concepts

  • Lazy migration: Data is migrated on read, not eagerly on startup.
  • Deterministic: Two devices migrating the same data produce identical results.
  • Linear chain: Migrations run v1→v2→v3→…→current, never skipping steps.
  • Compiled in: All migrations are embedded in the binary at compile time.

Structs§

MigrationConfig
Configuration for the migration engine.
MigrationEngine
The migration engine that runs a chain of migration steps.
VersionedEnvelope
A version envelope wrapping serialized CRDT data.

Enums§

CrdtType
Identifies the type of CRDT stored in the envelope.
MigrationError
Error during migration.

Constants§

ENVELOPE_HEADER_SIZE
Size of the version envelope header in bytes.
MAGIC_BYTE
Magic byte identifying crdt-kit serialized data.

Traits§

MigrationStep
A single migration step that transforms data from one version to the next.
Schema
Trait for types with a versioned schema.

Attribute Macros§

crdt_schema
Attribute macro that generates schema + versioning impls for a struct.
migration
Attribute macro that wraps a migration function into a MigrationStep.