generator

package
v0.9.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dot

func Dot(db *interpreter.Database) string

Dot generates a Graphviz DOT representation of the database schema.

func Dump

func Dump(db *interpreter.Database, d Dialect) string

Dump generates a full CREATE TABLE script for the given schema and dialect.

func IsNormalized

func IsNormalized(s string) bool

IsNormalized returns true if the database_type string has the " normalized" suffix.

func IsNormalizedDatabase

func IsNormalizedDatabase(db *interpreter.Database) bool

IsNormalizedDatabase returns true if the database has a " normalized" suffix in its database_type Project setting.

func Migrate

func Migrate(oldDB, newDB *interpreter.Database, d Dialect) string

Migrate generates ALTER TABLE statements to migrate oldDB to newDB.

Types

type Dialect

type Dialect int

Dialect represents the target SQL dialect.

const (
	// Generic is a passthrough dialect: types are emitted as-is without normalization or validation.
	Generic Dialect = iota
	Postgres
	MariaDB
	SQLite
)

func DialectFromDatabase

func DialectFromDatabase(db *interpreter.Database) Dialect

DialectFromDatabase extracts the SQL dialect from an interpreter.Database's Project.database_type setting. The " normalized" suffix is stripped before matching, so "MariaDB normalized" returns MariaDB.

func ParseDialect

func ParseDialect(s string) (Dialect, error)

ParseDialect parses a dialect name into a Dialect constant. Accepts driver names (postgres, mariadb, sqlite), DBML database_type values (PostgreSQL, MariaDB, SQLite), and aliases. A " normalized" suffix is stripped before matching (e.g. "MariaDB normalized" → MariaDB). An empty string or bare "normalized" returns Generic mode.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL