Documentation
¶
Overview ¶
Package schema provides database schema loading and management.
Index ¶
- type SchemaLoader
- func (l *SchemaLoader) GenerateSQL(driver database.DatabaseDriver) ([]string, error)
- func (l *SchemaLoader) GetAllSchemas() map[string]database.TableSchema
- func (l *SchemaLoader) GetSchema(tableName string) (database.TableSchema, bool)
- func (l *SchemaLoader) LoadAll() error
- func (l *SchemaLoader) LoadFile(filename string) error
- func (l *SchemaLoader) LoadFromString(yamlContent string) error
- type YAMLColumn
- type YAMLSchema
- type YAMLTable
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 ¶
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.