Skip to main content

Module schema_migration

Module schema_migration 

Source
Expand description

Schema migration detection and planning for SymbolTable evolution.

This module compares two SymbolTable versions, detects structural changes, and produces a structured SchemaMigrationPlan with actionable steps.

§Overview

The migration engine:

  1. Snapshots both old and new schemas via SchemaSnapshot
  2. Diffs predicates, domains, and variable bindings
  3. Optionally detects renames using Dice-bigram similarity
  4. Classifies each SchemaChange by ChangeSeverity
  5. Generates ordered SchemaMigrationSteps

§Example

use tensorlogic_adapters::{SymbolTable, DomainInfo, PredicateInfo};
use tensorlogic_adapters::schema_migration::{
    compute_migration, MigrationConfig, SchemaChange,
};

let mut old = SymbolTable::new();
old.add_domain(DomainInfo::new("Person", 100)).unwrap();
let mut new_schema = SymbolTable::new();
new_schema.add_domain(DomainInfo::new("Person", 100)).unwrap();
new_schema.add_domain(DomainInfo::new("Animal", 50)).unwrap();

let config = MigrationConfig::default();
let plan = compute_migration(&old, &new_schema, &config).unwrap();
assert!(!plan.is_empty());

Structs§

MigrationConfig
Configuration for the migration engine.
SchemaMigrationPlan
The full migration plan produced by compute_migration.
SchemaSnapshot
A lightweight snapshot of a SymbolTable for comparison purposes.

Enums§

ChangeSeverity
Severity classification for a schema change.
MigrationError
Error type for migration computation and validation.
SchemaChange
A single structural change detected between two schema versions.
SchemaMigrationStep
A concrete migration step to transform the old schema into the new schema.

Functions§

compute_migration
Compute the full migration plan needed to go from old_schema to new_schema.
string_similarity
Compute the Dice coefficient on character bigrams of two strings.
validate_plan
Validate that a migration plan is internally self-consistent.