Version: dev

can_migrate

Stable function · Versions and migration

Tier: stable · Kind: function · Topic: Versions and migration

JuliaTypeScriptPythonRustGo
can_migratecanMigratecan_migratecan_migrateCanMigrate

Julia

can_migrate(from_version::AbstractString, to_version::AbstractString)
can_migrate(from_version::AbstractString, to_version::AbstractString) -> Bool

Whether migrate would succeed for this version pair — i.e. whether to_version is among supported_migration_targets (from_version).

Deliberately consults the same single source of truth migrate does, so a caller is never told a pair is migratable and then handed a MigrationError.

Source

TypeScript

function canMigrate(sourceVersion: string, targetVersion: string): boolean

Check if migration is possible from the source version to target version.

Source

Python

can_migrate(from_version: str, to_version: str) -> bool

True when migrate would succeed for this version pair.

Source

Rust

pub fn can_migrate(from_version: &str, to_version: &str) -> bool

Whether migrate would succeed for this version pair — i.e. whether to_version is among supported_migration_targets (from_version).

Deliberately consults the same single source of truth migrate does, so a caller is never told a pair is migratable and then handed a MigrationError .

Source · Rust docs

Example (migrate)

// decay.esm is written at format 1.0.0; the current format is a newer
// 1.x, reached by a version-marker bump with no structural change.
assert_eq!(doc.esm, "1.0.0");
assert_eq!(supported_migration_targets(&doc.esm), [SCHEMA_VERSION]);
assert!(can_migrate(&doc.esm, SCHEMA_VERSION));
let migrated = migrate(&doc, SCHEMA_VERSION)?;
assert_eq!(migrated.esm, SCHEMA_VERSION);

// A 0.x document is out of reach: 1.0.0 was a clean break.
assert!(!can_migrate("0.9.0", SCHEMA_VERSION));

From docs/api/examples/rust/load.rs

Go

func CanMigrate(sourceVersion, targetVersion string) bool

CanMigrate reports whether a migration from sourceVersion to targetVersion is supported.

Source · Go docs