schema

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SchemaLoader

type SchemaLoader struct {
	// contains filtered or unexported fields
}

SchemaLoader loads YAML schema definitions

func NewSchemaLoader

func NewSchemaLoader(schemaDir string) *SchemaLoader

NewSchemaLoader creates a new schema loader

func (*SchemaLoader) GenerateSQL

func (l *SchemaLoader) GenerateSQL(driver database.DatabaseDriver) ([]string, error)

GenerateSQL generates SQL for all schemas using the specified driver

func (*SchemaLoader) GetAllSchemas

func (l *SchemaLoader) GetAllSchemas() map[string]database.TableSchema

GetAllSchemas returns all loaded schemas

func (*SchemaLoader) GetSchema

func (l *SchemaLoader) GetSchema(tableName string) (database.TableSchema, bool)

GetSchema returns a schema by table name

func (*SchemaLoader) LoadAll

func (l *SchemaLoader) LoadAll() error

LoadAll loads all YAML schema files from the schema directory

func (*SchemaLoader) LoadFile

func (l *SchemaLoader) LoadFile(filename string) error

LoadFile loads a single YAML schema file

func (*SchemaLoader) LoadFromString

func (l *SchemaLoader) LoadFromString(yamlContent string) error

LoadFromString loads schema from a YAML string (useful for testing)

type YAMLColumn

type YAMLColumn struct {
	Type     string      `yaml:"type"`
	Required bool        `yaml:"required"`
	Unique   bool        `yaml:"unique"`
	Default  interface{} `yaml:"default"`
	Index    bool        `yaml:"index"`
}

YAMLColumn represents a column definition in YAML

type YAMLSchema

type YAMLSchema struct {
	Tables map[string]YAMLTable `yaml:",inline"`
}

YAMLSchema represents the structure of a YAML schema file

type YAMLTable

type YAMLTable struct {
	PK         string                 `yaml:"pk"`
	Columns    map[string]YAMLColumn  `yaml:"columns"`
	Indexes    []string               `yaml:"indexes"`
	Unique     []string               `yaml:"unique"`
	Timestamps bool                   `yaml:"timestamps"`
	Meta       map[string]interface{} `yaml:"meta"`
}

YAMLTable represents a single table definition in YAML

Jump to

Keyboard shortcuts

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