pub struct ProjectState { /* private fields */ }Expand description
The fully owned schema produced by replaying migrations.
Implementations§
Source§impl ProjectState
impl ProjectState
Sourcepub fn from_schema(schema: &SchemaSet) -> Self
pub fn from_schema(schema: &SchemaSet) -> Self
Builds migration state from model-generated schema metadata.
Sourcepub fn from_app_schema(app: impl Into<String>, schema: &SchemaSet) -> Self
pub fn from_app_schema(app: impl Into<String>, schema: &SchemaSet) -> Self
Builds a historical state for models owned by one application. Model identity remains stable when a subsequent migration renames its table.
Sourcepub fn from_app_schemas<'app, 'schema>(
schemas: impl IntoIterator<Item = (&'app str, &'schema SchemaSet)>,
) -> Result<Self, MigrationError>
pub fn from_app_schemas<'app, 'schema>( schemas: impl IntoIterator<Item = (&'app str, &'schema SchemaSet)>, ) -> Result<Self, MigrationError>
Combines schemas while retaining each application’s model identity.
Sourcepub fn tables(&self) -> &[TableState]
pub fn tables(&self) -> &[TableState]
Returns tables in their current schema order.
Sourcepub fn objects(&self) -> &[SchemaObjectState]
pub fn objects(&self) -> &[SchemaObjectState]
Returns named non-model SQLite objects in migration order.
Sourcepub fn add_schema_object(
&mut self,
object: SchemaObjectState,
) -> Result<(), MigrationError>
pub fn add_schema_object( &mut self, object: SchemaObjectState, ) -> Result<(), MigrationError>
Adds an application-owned SQLite object to this state.
Sourcepub fn validate(&self) -> Result<(), MigrationError>
pub fn validate(&self) -> Result<(), MigrationError>
Checks structural invariants without consulting a live database.
Sourcepub fn models(&self) -> Vec<ModelState>
pub fn models(&self) -> Vec<ModelState>
Returns models in table order, omitting legacy tables with no known application/model identity.
Sourcepub fn diff(&self, desired: &Self) -> Result<Vec<StateChange>, MigrationError>
pub fn diff(&self, desired: &Self) -> Result<Vec<StateChange>, MigrationError>
Compares historical state with current model metadata without touching the database. Both states must have complete ModelKey coverage.