Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateName ¶
ValidateName checks if a name is valid (alphanumeric + underscore)
Types ¶
type Field ¶
type Field struct {
Name string `json:"name"`
Column string `json:"column"`
Type FieldType `json:"type"`
Description string `json:"description,omitempty"`
Primary bool `json:"primary,omitempty"`
Unique bool `json:"unique,omitempty"`
Required bool `json:"required,omitempty"`
Nullable bool `json:"nullable,omitempty"`
Default interface{} `json:"default,omitempty"`
Length int `json:"length,omitempty"`
Precision int `json:"precision,omitempty"`
Scale int `json:"scale,omitempty"`
AutoGen bool `json:"autoGen,omitempty"` // Auto-generated (e.g., timestamps)
References *Reference `json:"references,omitempty"`
}
Field represents a table column
type FieldType ¶
type FieldType string
FieldType represents supported field types
const ( FieldTypeString FieldType = "string" FieldTypeText FieldType = "text" FieldTypeInteger FieldType = "integer" FieldTypeBigInt FieldType = "bigint" FieldTypeFloat FieldType = "float" FieldTypeDecimal FieldType = "decimal" FieldTypeBoolean FieldType = "boolean" FieldTypeTimestamp FieldType = "timestamp" FieldTypeDate FieldType = "date" FieldTypeTime FieldType = "time" FieldTypeUUID FieldType = "uuid" FieldTypeJSON FieldType = "json" FieldTypeJSONB FieldType = "jsonb" FieldTypeBinary FieldType = "binary" FieldTypeEnum FieldType = "enum" )
type Index ¶
type Index struct {
Name string `json:"name"`
Columns []string `json:"columns"`
Unique bool `json:"unique,omitempty"`
Type string `json:"type,omitempty"` // btree, hash, gin, etc.
}
Index represents a database index
type Model ¶
type Model struct {
Name string `json:"name"`
Table string `json:"table"`
Description string `json:"description,omitempty"`
Fields []Field `json:"fields"`
Indexes []Index `json:"indexes,omitempty"`
Relations []Relation `json:"relations,omitempty"`
}
Model represents a database table
type Reference ¶
type Reference struct {
Model string `json:"model"`
Field string `json:"field"`
OnDelete string `json:"onDelete,omitempty"` // CASCADE, SET NULL, RESTRICT, etc.
OnUpdate string `json:"onUpdate,omitempty"`
}
Reference represents a foreign key reference
type Relation ¶
type Relation struct {
Name string `json:"name"`
Type RelationType `json:"type"`
Model string `json:"model"`
ForeignKey string `json:"foreignKey,omitempty"`
References string `json:"references,omitempty"`
Through string `json:"through,omitempty"` // For many-to-many
}
Relation represents relationships between models
type RelationType ¶
type RelationType string
RelationType represents relationship types
const ( RelationBelongsTo RelationType = "belongsTo" RelationHasOne RelationType = "hasOne" RelationHasMany RelationType = "hasMany" RelationManyToMany RelationType = "manyToMany" )
type Schema ¶
type Schema struct {
Version string `json:"version"`
Description string `json:"description,omitempty"`
Models map[string]Model `json:"models"`
}
Schema represents the complete database schema
func LoadFromFile ¶
LoadFromFile loads a schema from a JSON file
func (*Schema) SaveToFile ¶
SaveToFile saves a schema to a JSON file
Click to show internal directories.
Click to hide internal directories.