mod inspect;
mod model;
mod plan;
mod preflight;
mod render;
mod sync;
#[cfg(test)]
mod __tests__;
#[cfg(test)]
pub(super) use model::{ExistingIndex, ExistingTableSchema};
#[cfg(test)]
pub(super) use plan::plan_table_sync;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum SchemaSyncChangeKind {
CreatedTable,
AddedColumn,
RenamedColumn,
ModifiedColumn,
AddedPrimaryKey,
AddedIndex,
AddedCheck,
AddedForeignKey,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub struct SchemaSyncChange {
pub table: String,
pub object: String,
pub kind: SchemaSyncChangeKind,
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
#[non_exhaustive]
pub struct SchemaSyncReport {
pub tables: Vec<String>,
pub changes: Vec<SchemaSyncChange>,
}
#[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()
}
}