Skip to main content

remodel_core/sql/
mod.rs

1//! SQL DDL generation for the supported dialects.
2//!
3//! Each dialect implements the [`Dialect`] trait, which knows how to render
4//! [`DataType`](crate::models::types::DataType) values, identifier quoting,
5//! and dialect-specific clauses. The top-level entry point is
6//! [`LogicalModel::to_sql`].
7
8mod dialect;
9mod ddl;
10
11pub use dialect::{Dialect, MySql, Postgres, Sqlite, SqlDialect};
12
13use crate::models::logical::LogicalModel;
14
15impl LogicalModel {
16    /// Render this logical model as a SQL DDL script for the given dialect.
17    ///
18    /// Tables are emitted in author order, with primary keys inline and
19    /// foreign keys deferred to `ALTER TABLE` statements at the bottom of the
20    /// script (so that forward references between tables resolve cleanly).
21    pub fn to_sql(&self, dialect: SqlDialect) -> String {
22        ddl::render(self, dialect)
23    }
24}