Skip to main content

schema_diff

Function schema_diff 

Source
pub fn schema_diff(
    current: &DatabaseSchema,
    expected: &DatabaseSchema,
) -> SchemaDiff
Expand description

Compare two schemas and generate operations to transform current to expected.

§Example

use sqlmodel_schema::{expected_schema, Dialect};
use sqlmodel_schema::diff::schema_diff;

let current = introspector.introspect_all(&cx, &conn).await?;
let expected = expected_schema::<(Hero, Team)>(Dialect::Sqlite);

let diff = schema_diff(&current, &expected);
for op in &diff.operations {
    println!("  {:?}", op);
}