pub trait DatabaseDialect: Send + Sync {
// Required methods
fn kind(&self) -> DialectKind;
fn quote_ident(&self, name: &str) -> String;
fn history_table_ddl(&self, schema: &str, table: &str) -> String;
fn supports_transactional_ddl(&self) -> bool;
// Provided method
fn qualified_table(&self, schema: &str, table: &str) -> String { ... }
}Expand description
Describes how migrations should be split, locked, and tracked on a given engine.
All methods are pure — they operate on strings or return DDL templates and do
not touch a database connection. Connection-dependent operations live on
crate::db::DbClient.
Required Methods§
Sourcefn kind(&self) -> DialectKind
fn kind(&self) -> DialectKind
Which dialect this is.
Sourcefn quote_ident(&self, name: &str) -> String
fn quote_ident(&self, name: &str) -> String
Quote a SQL identifier for safe inclusion in dynamic SQL.
PostgreSQL uses double-quotes ("name"), MySQL uses backticks (\name``).
Doubles any embedded quote character to escape it.
Sourcefn history_table_ddl(&self, schema: &str, table: &str) -> String
fn history_table_ddl(&self, schema: &str, table: &str) -> String
DDL to (idempotently) create the schema-history table.
Returns one or more ;-separated statements. Caller is responsible for
executing them via the appropriate driver. Schema, table, and index names
are quoted with Self::quote_ident.
PostgreSQL uses TIMESTAMPTZ; MySQL uses TIMESTAMP (UTC by convention).
Both store the same logical columns.
Sourcefn supports_transactional_ddl(&self) -> bool
fn supports_transactional_ddl(&self) -> bool
Whether the engine supports atomic rollback of DDL inside a transaction.
PostgreSQL: true. MySQL: false (most DDL implicitly commits).
Used to gate --transaction batch mode — when this returns false,
callers should refuse the batch_transaction config or return a clear
error rather than silently no-op.
Provided Methods§
Sourcefn qualified_table(&self, schema: &str, table: &str) -> String
fn qualified_table(&self, schema: &str, table: &str) -> String
Produce a fully-qualified table reference (schema.table).
In MySQL the “schema” is the database; in PostgreSQL it’s a schema namespace.
Both use the same qualifier.identifier syntax in DDL, just with different
quoting characters — handled by Self::quote_ident.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".