schema-diff 0.7.0

A set of tools to manage relational database schemas
Documentation
use schema_model::model::column::Column;
use schema_model::model::constraint::Constraint;
use schema_model::model::enum_type::EnumType;
use schema_model::model::function::Function;
use schema_model::model::initial_data::InitialData;
use schema_model::model::key::Key;
use schema_model::model::other_sql::OtherSql;
use schema_model::model::procedure::Procedure;
use schema_model::model::relation::Relation;
use schema_model::model::table::Table;
use schema_model::model::trigger::Trigger;
use schema_model::model::types::DatabaseType;
use schema_model::model::view::View;

#[derive(Debug, Clone)]
pub enum SchemaChange {
    AddTable {
        table: Table,
    },
    DropTable {
        table_name: String,
    },
    AddColumn {
        table_name: String,
        column: Column,
    },
    DropColumn {
        table_name: String,
        column_name: String,
        rename_candidates: Vec<String>,
    },
    ModifyColumn {
        table_name: String,
        old_column: Column,
        new_column: Column,
    },
    AddKey {
        table_name: String,
        key: Key,
        /// 1-based position of `key` among the sibling keys the create path numbers it
        /// with - unique keys are numbered among the table's other unique keys, indexes
        /// among the table's other indexes - so a migration can reproduce the exact
        /// `ak_<table><n>` / `ix_<table><n>` name the create path would use.
        ordinal: usize,
    },
    DropKey {
        table_name: String,
        key: Key,
        /// See `AddKey::ordinal`.
        ordinal: usize,
    },
    AddConstraint {
        table_name: String,
        constraint: Constraint,
    },
    DropConstraint {
        table_name: String,
        constraint_name: String,
        database_type: Option<DatabaseType>,
    },
    AddRelation {
        relation: Relation,
        /// 1-based position of `relation` among its table's relations, matching the
        /// create path's `fk_<table><n>` numbering.
        ordinal: usize,
    },
    DropRelation {
        relation: Relation,
        /// See `AddRelation::ordinal`.
        ordinal: usize,
    },
    AddView {
        view: View,
    },
    DropView {
        view_name: String,
        database_type: Option<DatabaseType>,
    },
    AddEnumType {
        enum_type: EnumType,
    },
    DropEnumType {
        enum_type_name: String,
    },
    ModifyEnumType {
        old_enum_type: EnumType,
        new_enum_type: EnumType,
    },
    AddFunction {
        function: Function,
    },
    DropFunction {
        function_name: String,
        database_type: DatabaseType,
    },
    AddProcedure {
        procedure: Procedure,
    },
    DropProcedure {
        procedure_name: String,
        database_type: DatabaseType,
    },
    AddOtherSql {
        other_sql: OtherSql,
    },
    DropOtherSql {
        other_sql: OtherSql,
    },
    AddTrigger {
        table_name: String,
        trigger: Trigger,
    },
    DropTrigger {
        table_name: String,
        trigger: Trigger,
    },
    AddInitialData {
        table_name: String,
        initial_data: InitialData,
    },
    DropInitialData {
        table_name: String,
        initial_data: InitialData,
    },
}