Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TopologicalSort ¶ added in v0.0.4
TopologicalSort returns models sorted so parents come before children (Kahn's BFS). Models not implementing SchemaExt() are treated as having no FK deps. Returns error on circular FK dependency. Moved here from tinywasm/ddlc: ordering CREATE TABLE statements by FK dependency is a DDL concern, not a generation-tool concern — see DDLC_DEPENDENCY_PROPOSAL.md in tinywasm/app-releases/docs.
Types ¶
type ColumnInfo ¶ added in v0.0.2
ColumnInfo describes a single column returned by SchemaInspector.
type Compiler ¶ added in v0.0.2
Compiler is implemented by dialect adapters (sqlt, postgres). It renders a DDL Stmt to engine SQL. It is the DDL counterpart of storage.Compiler (which stays DML-only).
type DB ¶ added in v0.0.2
type DB struct {
// contains filtered or unexported fields
}
DB applies schema changes through a storage.Conn: Exec for the compiled DDL, and Compile (the DML half storage.Conn already carries) for Sync's safe-drop SELECT probe. No separate DML compiler argument is needed — storage.Conn already unifies Executor+Compiler.
func (*DB) CreateDatabase ¶ added in v0.0.2
CreateDatabase creates a new database. No model.Model needed — OpCreateDatabase only carries the database name.
func (*DB) CreateTable ¶ added in v0.0.2
CreateTable creates a new table for the given model.
type Op ¶ added in v0.0.2
type Op int
Op is a DDL operation (schema), distinct from storage's DML Action.
type RenameProvider ¶ added in v0.0.2
RenameProvider is implemented by generated models when db:"old_name=X" tags are present.
type SchemaInspector ¶ added in v0.0.2
type SchemaInspector interface {
Tables() ([]string, error)
Columns(table string) ([]ColumnInfo, error)
}
SchemaInspector is optionally implemented by storage.Conn to expose broader schema introspection. If the adapter does not implement it, the db_schema MCP tool is not registered.
type Stmt ¶ added in v0.0.2
type Stmt struct {
Op Op
Table string
Database string
Column *model.Field // for AddColumn/RenameColumn — full field metadata needed to render the type
OldName string // for RenameColumn
// ColumnName carries a bare column name for operations that don't need type info —
// currently only OpDropColumn (you can't "add" or "rename to" a column without knowing
// its type, but dropping only needs the name). Deliberately separate from Column: giving
// DropColumn a *model.Field would force callers to fabricate a fake Field just to carry a
// string, which is worse than a second field that's simply unused by the other Ops.
ColumnName string
}
Stmt is one DDL statement to run through a storage.Conn.
type TableIntrospector ¶ added in v0.0.2
TableIntrospector is optionally implemented by the injected storage.Conn to retrieve column names.