idiolect-migrate
Source:
crates/idiolect-migrate/This crate is
publish = falseand is not on docs.rs. The authoritative reference is the source above plus the rustdoc built locally withcargo doc -p idiolect-migrate --open.
Schema-diff classification plus lens-based record migration.
Thin typed façade over panproto-check (for diff classification)
and idiolect-lens (for record translation).
Because the crate is publish = false, depend via git or path:
[dependencies]
idiolect-migrate = { git = "https://github.com/idiolect-dev/idiolect", tag = "v0.8.0" }
Public surface
The crate exposes:
classify(src, tgt)— runs the panproto diff and returns aCompatReportdistinguishing compatible from breaking changes.plan_auto(src, tgt, hints)— for breaking diffs that are covered by shipped migration recipes, returns aMigrationPlancarrying source / target schema hashes plus a lens body the caller can publish. For breaking diffs that resist automation, returnsErr(PlannerError::NotAutoDerivable)listing the offending changes.migrate_record(lens, source_record, schema_loader)— wrapsidiolect_lens::apply_lensfor the one-shot case.MigrationPlan— the typed plan struct.MigrateError,MigrateResult,PlannerError— the error types.- Re-exported
CompatReportandSchemaDifffrompanproto-checkfor convenience.
Migration shapes
| Diff | Behavior |
|---|---|
| Non-breaking (added optional, added vertex, added edge) | classify returns compatible = true; no plan is needed. |
| Auto-derivable breaking (removed optional, renamed vertex via hint) | plan_auto returns a MigrationPlan with a protolens-chain body. |
| Non-auto breaking (removed required, changed required type, added required without default) | plan_auto returns NotAutoDerivable. The caller writes the lens by hand. |
Why this is a separate crate from idiolect-lens
Two reasons:
- The migration-shaped API (classify-then-plan-then-migrate)
is a different shape than the runtime API
(
apply_lensplus resolvers). idiolect-migratedepends onpanproto-check, which is a heavier dep than the lens runtime itself. Keeping it separate keeps the runtime crate's compile-time small.
Scope
The crate owns no runtime state. It is a thin façade; the
runtime cost of a migration equals the cost of one apply_lens
per record.