use crate::{Schema, CompatibilityReport, MigrationPlan, ValidationResult, error::Result};
use serde::{Serialize, Deserialize};
use std::collections::HashMap;
pub mod json_schema;
pub mod protobuf;
pub mod openapi;
pub mod sql;
pub trait SchemaAnalyzer {
fn analyze_compatibility(&self, old: &Schema, new: &Schema) -> Result<CompatibilityReport>;
fn generate_migration_path(&self, old: &Schema, new: &Schema) -> Result<MigrationPlan>;
fn validate_changes(&self, changes: &[SchemaChange]) -> Result<ValidationResult>;
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SchemaChange {
pub change_type: ChangeType,
pub location: String,
pub description: String,
pub metadata: HashMap<String, String>,
}
impl SchemaChange {
pub fn new(
change_type: ChangeType,
location: impl Into<String>,
description: impl Into<String>,
metadata: HashMap<String, String>,
) -> Self {
SchemaChange {
change_type,
location: location.into(),
description: description.into(),
metadata,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum ChangeType {
Addition,
Removal,
Modification,
Rename,
}