Skip to main content

Crate perspective_migrate

Crate perspective_migrate 

Source
Expand description

Upgrades persisted Perspective configs — engine ViewConfigs, <perspective-viewer> tokens and workspaces — written by any release since 2.0.0 to the current schema.

use perspective_migrate::{Kind, Migrator};
use serde_json::json;

let migrated = Migrator::new()
    .migrate(Kind::View, Some("2.6.0"), json!({
        "row_pivot": ["State"],
        "expressions": ["//profit\n\"Sales\" - \"Cost\""]
    }))
    .unwrap();

assert_eq!(migrated.value, json!({
    "group_by": ["State"],
    "expressions": {"profit": "\"Sales\" - \"Cost\""}
}));

Structs§

Migrated
A migrated config and what the migration could not carry over exactly.
Migrator
Upgrades configs through every schema change since their source version.
Step
One schema change: apply runs on every object it concerns when the source version predates at.
StepCx
The context a Step runs in.
Version
A Perspective release, ordered by major.minor.patch with any pre-release or build suffix ignored.

Enums§

Kind
The kind of document a config is.
MigrateError
Why a config could not be migrated to a valid current form.
Notice
Information a migration could not carry into the current schema exactly.

Traits§

PluginMigration
The migrations of a plugin’s plugin_config and columns_config, whose Step::at versions are the Perspective release that wrote a token rather than releases of the plugin itself.

Functions§

migrate
Upgrade a persisted Perspective config to the current schema, returning {value, notices, steps}.

Type Aliases§

Apply
Rewrites one config object from the shape before Step::at to the shape after it.