Repository navigation
Closed
Description
Goal
Enable safe, incremental schema changes across database lifetimes without data loss or silent corruption. When a component's struct definition changes (fields added, removed, reordered, types widened, or types changed), Typhon should detect the mismatch, auto-resolve compatible changes, and support user-defined migration functions for breaking changes.
Current State (Unsafe)
Today, RegisterComponentFromAccessor<T>() blindly trusts the runtime struct — no validation against persisted metadata. If the struct layout changes between sessions, the result is silent data corruption or crashes. FieldIds are assigned by declaration order, so inserting a field shifts all subsequent IDs and breaks B+Tree index associations.
Design Reference
- Schema Versioning Design Series (5-part design)
- Decision log: D1-D8 (FieldId hybrid assignment, PreviousName, eager migration, chunkId preservation, safe type widenings)
Architecture
Layer 4: Operational Tooling — Schema history, dry-run, tsh commands
Layer 3: Migration Functions — User-defined transforms, migration registry
Layer 2: Compatible Evolution — Add/remove/reorder/widen fields, add/remove indexes
Layer 1: Schema Validation — SchemaDiff engine, reopen-time checks, error reporting
Layer 0: FieldId Stability — Persistent name-based assignment, PreviousName, dense array
Sub-Issues (5 Phases)
Phase 1 — FieldId Stability (Foundation)
- Phase 1: FieldId Stability #100 Phase 1: FieldId Stability
Phase 2 — Schema Validation (Safety Net)
- Phase 2: Schema Validation #101 Phase 2: Schema Validation
Phase 3 — Compatible Evolution (Automatic Changes)
- Phase 3: Compatible Evolution #102 Phase 3: Compatible Evolution
Phase 4 — Migration Functions (User Transforms)
- Phase 4: Migration Functions #103 Phase 4: Migration Functions
Phase 5 — Operational Tooling (Production Support)
- Phase 5: Operational Tooling #104 Phase 5: Operational Tooling
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Priority
None yet
Activity
Schema Versioning & Evolution (#99) (#106)