modelvault_core/migration.rs
1//! Migration planning and helpers.
2//!
3//! ModelVault keeps schema evolution conservative by default. When a proposed schema change requires
4//! rewriting existing data (e.g. adding a required field), callers can plan and then execute a
5//! migration using helpers provided here.
6
7use crate::schema::SchemaChange;
8
9#[derive(Debug, Clone, PartialEq, Eq)]
10pub enum MigrationStep {
11 /// Backfill a missing top-level field for all existing rows in a collection.
12 BackfillTopLevelField { field: String },
13 /// Backfill a missing field at a multi-segment path for all existing rows.
14 BackfillFieldAtPath { path: crate::schema::FieldPath },
15 /// Rebuild index entries for a collection (typically after adding a new index definition).
16 RebuildIndexes,
17}
18
19#[derive(Debug, Clone, PartialEq, Eq)]
20pub struct MigrationPlan {
21 pub change: SchemaChange,
22 pub steps: Vec<MigrationStep>,
23}