mod binding;
mod dialect;
mod driver;
#[cfg(feature = "mysql")]
mod inspect;
mod model;
#[cfg(feature = "postgres")]
mod pg;
mod plan;
mod preflight;
#[cfg(feature = "mysql")]
mod render;
mod sync;
#[cfg(test)]
mod __tests__;
pub use binding::SchemaBindingMode;
#[cfg(all(test, feature = "mysql"))]
pub(super) use model::SchemaPreflightCheck;
#[cfg(test)]
pub(super) use model::{ExistingIndex, ExistingTableSchema};
#[cfg(all(test, feature = "mysql"))]
pub(super) use plan::plan_table_sync;
#[cfg(all(test, feature = "postgres"))]
pub(super) use plan::plan_table_sync_with;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum SchemaSyncChangeKind {
CreatedTable,
AddedColumn,
RenamedColumn,
ModifiedColumn,
AddedPrimaryKey,
AddedIndex,
CreatedEnumType,
AddedEnumValue,
AddedCheck,
ValidatedCheck,
CommentedColumn,
AddedForeignKey,
ValidatedForeignKey,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub struct SchemaSyncChange {
pub table: String,
pub object: String,
pub kind: SchemaSyncChangeKind,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub struct SchemaBindingChange {
pub datasource: crate::datasource::DatasourceId,
pub table: String,
pub mode: SchemaBindingMode,
pub newly_bound: bool,
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
#[non_exhaustive]
pub struct SchemaSyncReport {
pub tables: Vec<String>,
pub changes: Vec<SchemaSyncChange>,
pub statements: Vec<String>,
pub deferred_statements: Vec<String>,
pub bindings: Vec<SchemaBindingChange>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub struct SchemaDataViolation {
pub table: String,
pub object: String,
pub primary_keys: Vec<String>,
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
#[non_exhaustive]
pub struct SchemaPreflightReport {
pub plan: SchemaSyncReport,
pub violations: Vec<SchemaDataViolation>,
}
impl SchemaPreflightReport {
pub fn is_safe(&self) -> bool {
self.violations.is_empty()
}
}
impl SchemaSyncReport {
pub fn is_noop(&self) -> bool {
self.changes.is_empty()
}
}