Module schema_evolution

Module schema_evolution 

Source
Expand description

Schema Evolution - Online Schema Changes

This module provides backwards-compatible schema evolution for SochDB, allowing schema changes without full table rewrites through:

  • Schema Versioning: Each schema has a monotonic version number
  • Migration Registry: Registered transformations between versions
  • Lazy Migration: Rows are migrated on-read when version mismatch detected
  • Background Compaction: Asynchronous migration during idle time

§Design

┌─────────────────────────────────────────────────────────────┐
│                    Schema Version Graph                      │
│                                                             │
│  v1 ──────────────────────────────────────────────────────→ │
│   ↓                                                         │
│  v2 (add column "email")                                    │
│   ↓                                                         │
│  v3 (rename "name" → "full_name", add "created_at")        │
│   ↓                                                         │
│  v4 (drop "legacy_field")                                   │
└─────────────────────────────────────────────────────────────┘

Rows carry their schema version. On read:
1. Check row version vs current schema version
2. If mismatch, apply migration chain (v_row → v_current)
3. Return migrated row (optionally rewrite in background)

Structs§

EvolutionStats
Statistics for schema evolution operations
EvolutionStatsSnapshot
Migration
Migration between two schema versions
SchemaEvolutionManager
Schema evolution manager that wraps a registry with additional features
SchemaId
Unique schema identifier (table/collection name + version)
SchemaRegistry
Schema version registry with migration graph
VersionedRow
Row with embedded schema version for lazy migration

Enums§

SchemaChange
Describes a single schema change operation
TypeConverter
Type conversion function for schema evolution

Type Aliases§

SchemaVersion
Schema version identifier