Skip to main content

DdlGenerator

Trait DdlGenerator 

Source
pub trait DdlGenerator {
    // Required methods
    fn dialect(&self) -> &'static str;
    fn generate(&self, op: &SchemaOperation) -> Vec<String>;

    // Provided methods
    fn generate_all(&self, ops: &[SchemaOperation]) -> Vec<String> { ... }
    fn generate_rollback(&self, ops: &[SchemaOperation]) -> Vec<String> { ... }
}
Expand description

Generates DDL SQL statements from schema operations.

Required Methods§

Source

fn dialect(&self) -> &'static str

The database dialect name.

Source

fn generate(&self, op: &SchemaOperation) -> Vec<String>

Generate DDL statement(s) for a single schema operation.

Some operations (like SQLite DROP COLUMN) may produce multiple statements.

Provided Methods§

Source

fn generate_all(&self, ops: &[SchemaOperation]) -> Vec<String>

Generate DDL statements for multiple operations.

Source

fn generate_rollback(&self, ops: &[SchemaOperation]) -> Vec<String>

Generate rollback DDL statements (inverse operations).

Returns statements in reverse order, suitable for undoing the original operations. Operations without an inverse (like DROP TABLE) are skipped.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§