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 an Execer: Exec for the compiled DDL. When the connection also satisfies storage.Compiler and exposes Query, Sync additionally runs its safe-drop probe (see sync.go); when it does not, Sync takes the additive path that needs neither.
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 Execer ¶ added in v0.0.12
Execer is the only capability ddl.DB always needs from its connection: somewhere to send compiled DDL. Everything else Sync can use — storage.Compiler and Query for the safe-drop probe, storage.TxExecutor for transactional sync, TableIntrospector/SchemaInspector for reconciliation — is optional and discovered by type assertion, so requiring the full storage.Conn here excluded connections that legitimately execute DDL and nothing else (a CI migration transport over an HTTP API, for instance). storage.Conn satisfies this interface, so every existing caller is unaffected.
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.