Documentation
¶
Overview ¶
MIT License
Copyright (c) 2025 OcomSoft ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2025 OcomSoft ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2025 OcomSoft ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2025 OcomSoft ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2025 OcomSoft ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2025 OcomSoft ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2025 OcomSoft ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2025 OcomSoft ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2025 OcomSoft ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2025 OcomSoft ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2025 OcomSoft ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- Constants
- Variables
- func IsDestructiveOperation(changeType ChangeType) bool
- type Change
- type ChangeType
- type Database
- type DatabaseType
- type Defaults
- type Dependency
- type DependencyAnalyzer
- func (a *DependencyAnalyzer) AnalyzeDependencies(schema *Schema) ([]Dependency, error)
- func (a *DependencyAnalyzer) GenerateJunctionTables(schema *Schema) ([]Table, error)
- func (a *DependencyAnalyzer) GetDependentTables(schema *Schema, tableName string) ([]string, error)
- func (a *DependencyAnalyzer) GetManyToManyRelationships(schema *Schema) []Dependency
- func (a *DependencyAnalyzer) GetReferencedTables(schema *Schema, tableName string) ([]string, error)
- func (a *DependencyAnalyzer) TopologicalSort(schema *Schema) ([]string, error)
- func (a *DependencyAnalyzer) ValidateCircularDependencies(schema *Schema) error
- type DiffEngine
- func (de *DiffEngine) CompareSchemas(oldSchema, newSchema *Schema) (*SchemaDiff, error)
- func (de *DiffEngine) GenerateMigrationName(diff *SchemaDiff) string
- func (de *DiffEngine) GetChangesByType(diff *SchemaDiff, changeType ChangeType) []Change
- func (de *DiffEngine) GetDestructiveChanges(diff *SchemaDiff) []Change
- func (de *DiffEngine) HasDestructiveChanges(diff *SchemaDiff) bool
- type Field
- type ForeignKey
- type Include
- type IncludeProcessor
- type Index
- type ManyToMany
- type Merger
- type ModuleResolver
- type Parser
- func (p *Parser) FormatValidationErrors(errors []ValidationError) string
- func (p *Parser) GetDefaultValue(schema *Schema, dbType DatabaseType, defaultKey string) (string, error)
- func (p *Parser) ParseAndValidate(content string) (*Schema, error)
- func (p *Parser) ParseSchema(content string) (*Schema, error)
- func (p *Parser) ParseSchemaFile(filePath string) (*Schema, error)
- func (p *Parser) ParseSchemaFileWithContent(content, filePath string) (*Schema, error)
- func (p *Parser) ValidateComprehensive(schema *Schema, databaseType DatabaseType) []ValidationError
- func (p *Parser) ValidateDatabaseSpecificRules(schema *Schema, databaseType DatabaseType) error
- func (p *Parser) ValidateForeignKeyReferences(schema *Schema) error
- func (p *Parser) ValidateSchemaStructure(schema *Schema) error
- type PromptFunc
- type PromptResponse
- type SQLConverter
- type Schema
- type SchemaDiff
- type StateManager
- func (sm *StateManager) BackupSnapshot(migrationsDir string) error
- func (sm *StateManager) CompareSnapshots(schema1, schema2 *Schema) bool
- func (sm *StateManager) CreateInitialSnapshot(databaseName string, migrationsDir string) error
- func (sm *StateManager) GetSnapshotPath(migrationsDir string) string
- func (sm *StateManager) LoadSchemaSnapshot(migrationsDir string) (*Schema, error)
- func (sm *StateManager) SaveSchemaSnapshot(schema *Schema, migrationsDir string) error
- func (sm *StateManager) SchemaSnapshotExists(migrationsDir string) bool
- func (sm *StateManager) ValidateSnapshot(migrationsDir string) error
- type Table
- type TypeMappings
- type ValidationError
Constants ¶
const ( FieldTypeVarchar = "varchar" FieldTypeText = "text" FieldTypeInteger = "integer" FieldTypeBigint = "bigint" FieldTypeSerial = "serial" FieldTypeFloat = "float" FieldTypeDecimal = "decimal" FieldTypeBoolean = "boolean" FieldTypeDate = "date" FieldTypeTime = "time" FieldTypeTimestamp = "timestamp" FieldTypeUUID = "uuid" FieldTypeJSON = "json" FieldTypeJSONB = "jsonb" FieldTypeForeignKey = "foreign_key" )
Field types
const ( SQLTypeText = "TEXT" SQLTypeInteger = "INTEGER" SQLTypeInt = "INT" SQLTypeBigint = "BIGINT" SQLTypeFloat = "FLOAT" SQLTypeReal = "REAL" SQLTypeDecimal = "DECIMAL" SQLTypeBoolean = "BOOLEAN" SQLTypeDate = "DATE" SQLTypeTime = "TIME" SQLTypeTimestamp = "TIMESTAMP" SQLTypeUUID = "UUID" SQLTypeChar36 = "CHAR(36)" SQLTypeUniqueIdentifier = "UNIQUEIDENTIFIER" SQLTypeJSONB = "JSONB" SQLTypeNVarcharMax = "NVARCHAR(MAX)" )
SQL types
const ( DatabasePostgreSQL = types.DatabasePostgreSQL DatabaseMySQL = types.DatabaseMySQL DatabaseSQLServer = types.DatabaseSQLServer DatabaseSQLite = types.DatabaseSQLite )
Re-export constants
const (
DefaultMigrationsDir = "migrations"
)
Common values
Variables ¶
var IsValidDatabase = types.IsValidDatabase
var IsValidFieldType = types.IsValidFieldType
var ParseDatabaseType = types.ParseDatabaseType
Re-export functions
var ValidFieldTypes = types.ValidFieldTypes
Re-export variables
Functions ¶
func IsDestructiveOperation ¶
func IsDestructiveOperation(changeType ChangeType) bool
IsDestructiveOperation returns true if the operation type may cause data loss. Exported so callers outside this package (e.g. cmd) can apply the same logic when building per-change decisions before code generation.
Types ¶
type Change ¶
type Change struct {
Type ChangeType `json:"type"`
TableName string `json:"table_name"`
FieldName string `json:"field_name,omitempty"`
Description string `json:"description"`
OldValue interface{} `json:"old_value,omitempty"`
NewValue interface{} `json:"new_value,omitempty"`
Destructive bool `json:"destructive"`
}
Change represents a structural change between schemas
type ChangeType ¶
type ChangeType string
ChangeType represents the type of change
const ( ChangeTypeTableAdded ChangeType = "table_added" ChangeTypeTableRemoved ChangeType = "table_removed" ChangeTypeTableRenamed ChangeType = "table_renamed" ChangeTypeFieldAdded ChangeType = "field_added" ChangeTypeFieldRemoved ChangeType = "field_removed" ChangeTypeFieldRenamed ChangeType = "field_renamed" ChangeTypeFieldModified ChangeType = "field_modified" ChangeTypeIndexAdded ChangeType = "index_added" ChangeTypeIndexRemoved ChangeType = "index_removed" ChangeTypeForeignKeyAdded ChangeType = "foreign_key_added" ChangeTypeForeignKeyRemoved ChangeType = "foreign_key_removed" ChangeTypeDefaultsModified ChangeType = "defaults_modified" // non-destructive: updates active schema defaults ChangeTypeTypeMappingsModified ChangeType = "type_mappings_modified" // non-destructive: updates active provider type mappings )
type DatabaseType ¶
type DatabaseType = types.DatabaseType
type Dependency ¶
type Dependency struct {
FromTable string
ToTable string
FieldName string
Type string // "foreign_key" or "many_to_many"
}
Dependency represents a foreign key dependency between tables
type DependencyAnalyzer ¶
type DependencyAnalyzer struct {
// contains filtered or unexported fields
}
DependencyAnalyzer handles foreign key dependency analysis and topological sorting for YAML schemas
func NewDependencyAnalyzer ¶
func NewDependencyAnalyzer(verbose bool) *DependencyAnalyzer
NewDependencyAnalyzer creates a new YAML dependency analyzer
func (*DependencyAnalyzer) AnalyzeDependencies ¶
func (a *DependencyAnalyzer) AnalyzeDependencies(schema *Schema) ([]Dependency, error)
AnalyzeDependencies analyzes foreign key dependencies in a YAML schema
func (*DependencyAnalyzer) GenerateJunctionTables ¶
func (a *DependencyAnalyzer) GenerateJunctionTables(schema *Schema) ([]Table, error)
GenerateJunctionTables generates junction table definitions for many-to-many relationships
func (*DependencyAnalyzer) GetDependentTables ¶
func (a *DependencyAnalyzer) GetDependentTables(schema *Schema, tableName string) ([]string, error)
GetDependentTables returns all tables that depend on the given table
func (*DependencyAnalyzer) GetManyToManyRelationships ¶
func (a *DependencyAnalyzer) GetManyToManyRelationships(schema *Schema) []Dependency
GetManyToManyRelationships returns all many-to-many relationships in the schema
func (*DependencyAnalyzer) GetReferencedTables ¶
func (a *DependencyAnalyzer) GetReferencedTables(schema *Schema, tableName string) ([]string, error)
GetReferencedTables returns all tables that the given table references
func (*DependencyAnalyzer) TopologicalSort ¶
func (a *DependencyAnalyzer) TopologicalSort(schema *Schema) ([]string, error)
TopologicalSort sorts tables based on their foreign key dependencies
func (*DependencyAnalyzer) ValidateCircularDependencies ¶
func (a *DependencyAnalyzer) ValidateCircularDependencies(schema *Schema) error
ValidateCircularDependencies checks for circular dependencies in the schema
type DiffEngine ¶
type DiffEngine struct {
// contains filtered or unexported fields
}
DiffEngine handles YAML schema comparison and diff generation
func NewDiffEngine ¶
func NewDiffEngine(verbose bool) *DiffEngine
NewDiffEngine creates a new YAML diff engine
func (*DiffEngine) CompareSchemas ¶
func (de *DiffEngine) CompareSchemas(oldSchema, newSchema *Schema) (*SchemaDiff, error)
CompareSchemas compares two YAML schemas and returns the differences
func (*DiffEngine) GenerateMigrationName ¶
func (de *DiffEngine) GenerateMigrationName(diff *SchemaDiff) string
GenerateMigrationName generates a meaningful migration name from changes
func (*DiffEngine) GetChangesByType ¶
func (de *DiffEngine) GetChangesByType(diff *SchemaDiff, changeType ChangeType) []Change
GetChangesByType returns changes filtered by type
func (*DiffEngine) GetDestructiveChanges ¶
func (de *DiffEngine) GetDestructiveChanges(diff *SchemaDiff) []Change
GetDestructiveChanges returns only destructive changes
func (*DiffEngine) HasDestructiveChanges ¶
func (de *DiffEngine) HasDestructiveChanges(diff *SchemaDiff) bool
HasDestructiveChanges checks if the diff contains destructive changes
type ForeignKey ¶
type ForeignKey = types.ForeignKey
type IncludeProcessor ¶
type IncludeProcessor struct {
// contains filtered or unexported fields
}
IncludeProcessor handles processing schema includes with circular dependency tracking
func NewIncludeProcessor ¶
func NewIncludeProcessor(verbose bool) *IncludeProcessor
NewIncludeProcessor creates a new include processor
func (*IncludeProcessor) ProcessIncludes ¶
func (ip *IncludeProcessor) ProcessIncludes(schema *Schema, currentFile string) (*Schema, error)
ProcessIncludes processes all includes in a schema recursively
func (*IncludeProcessor) Reset ¶
func (ip *IncludeProcessor) Reset()
Reset clears the processed file tracking (useful for testing)
type ManyToMany ¶
type ManyToMany = types.ManyToMany
type Merger ¶
type Merger struct {
// contains filtered or unexported fields
}
Merger handles YAML schema merging with conflict resolution
func (*Merger) GetMergedFieldNames ¶
GetMergedFieldNames returns the names of all fields that were merged within each table
func (*Merger) GetMergedTableNames ¶
GetMergedTableNames returns the names of all tables that were merged from multiple definitions
func (*Merger) MergeSchemas ¶
MergeSchemas merges multiple YAML schemas into a single unified schema
func (*Merger) ValidateMergedSchema ¶
ValidateMergedSchema validates the merged schema for consistency
type ModuleResolver ¶
type ModuleResolver struct {
// contains filtered or unexported fields
}
ModuleResolver handles resolving Go module paths to filesystem paths without shelling out to `go list`. It reads go.mod and go.work directly.
func NewModuleResolver ¶
func NewModuleResolver(verbose bool) *ModuleResolver
NewModuleResolver creates a new module resolver
func (*ModuleResolver) ResolveIncludePath ¶
func (mr *ModuleResolver) ResolveIncludePath(include Include) (string, error)
ResolveIncludePath resolves a module + path combination to a full file path
func (*ModuleResolver) ResolveModulePath ¶
func (mr *ModuleResolver) ResolveModulePath(modulePath string) (string, error)
ResolveModulePath resolves a Go module path to a filesystem directory. Resolution order: go.mod replace directives, go.work workspace members, then the Go module cache under GOPATH.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser handles YAML schema parsing and validation
func (*Parser) FormatValidationErrors ¶
func (p *Parser) FormatValidationErrors(errors []ValidationError) string
FormatValidationErrors formats validation errors for display
func (*Parser) GetDefaultValue ¶
func (p *Parser) GetDefaultValue(schema *Schema, dbType DatabaseType, defaultKey string) (string, error)
GetDefaultValue gets the default value for a database type
func (*Parser) ParseAndValidate ¶
ParseAndValidate parses and fully validates a YAML schema
func (*Parser) ParseSchema ¶
ParseSchema parses a YAML schema string into a Schema struct
func (*Parser) ParseSchemaFile ¶
ParseSchemaFile parses a YAML schema file and processes includes
func (*Parser) ParseSchemaFileWithContent ¶
ParseSchemaFileWithContent parses YAML content and processes includes
func (*Parser) ValidateComprehensive ¶
func (p *Parser) ValidateComprehensive(schema *Schema, databaseType DatabaseType) []ValidationError
ValidateComprehensive performs all validation checks with detailed error reporting
func (*Parser) ValidateDatabaseSpecificRules ¶
func (p *Parser) ValidateDatabaseSpecificRules(schema *Schema, databaseType DatabaseType) error
ValidateDatabaseSpecificRules validates database-specific rules
func (*Parser) ValidateForeignKeyReferences ¶
ValidateForeignKeyReferences validates that all foreign key references exist
func (*Parser) ValidateSchemaStructure ¶
ValidateSchemaStructure performs additional structural validation
type PromptFunc ¶
type PromptFunc func(sqlStmt string, change Change) (PromptResponse, error)
PromptFunc is called when a destructive operation is detected during SQL conversion. It receives the SQL statement and change details, and returns the user's choice. Implementations can use any UI (bubbletea TUI, plain stdin, etc.).
type PromptResponse ¶
type PromptResponse int
PromptResponse represents the user's response to a destructive operation prompt
const ( PromptGenerate PromptResponse = 1 // Generate SQL without any prefix PromptReview PromptResponse = 2 // Mark for review (use review prefix) PromptOmit PromptResponse = 3 // Don't generate statement (omit from output) PromptExit PromptResponse = 4 // Exit migration generation PromptGenerateAll PromptResponse = 5 // Generate all remaining destructive operations without prompting PromptIgnoreErrors PromptResponse = 6 // Generate with IgnoreErrors: true (runner continues on failure) )
type SQLConverter ¶
type SQLConverter struct {
// contains filtered or unexported fields
}
SQLConverter converts YAML schema definitions to database-specific SQL DDL.
Per-change-type operation handlers live in sql_operations.go. Review comment logic lives in sql_review.go.
func NewSQLConverter ¶
func NewSQLConverter(databaseType DatabaseType, verbose bool) *SQLConverter
NewSQLConverter creates a new SQL converter
func NewSQLConverterWithConfig ¶
func NewSQLConverterWithConfig(databaseType DatabaseType, verbose bool, safeTypeChanges bool, reviewPrefix string, destructiveOps []string, silent bool, rejectionPrefix string, promptFn ...PromptFunc) *SQLConverter
NewSQLConverterWithConfig creates a new SQL converter with full configuration. The promptFn parameter is called for destructive operations. When nil or when silent is true, destructive operations default to PromptReview (mark for review).
func NewSQLConverterWithOptions ¶
func NewSQLConverterWithOptions(databaseType DatabaseType, verbose bool, safeTypeChanges bool) *SQLConverter
NewSQLConverterWithOptions creates a new SQL converter with configuration options
func (*SQLConverter) ConvertDiffToSQL ¶
func (sc *SQLConverter) ConvertDiffToSQL(diff *SchemaDiff, oldSchema, newSchema *Schema) (upSQL, downSQL string, err error)
ConvertDiffToSQL converts a YAML schema diff to SQL migration statements
func (*SQLConverter) ConvertSchema ¶
func (sc *SQLConverter) ConvertSchema(schema *Schema) (string, error)
ConvertSchema converts a complete YAML schema to SQL DDL statements
func (*SQLConverter) ConvertTable ¶
func (sc *SQLConverter) ConvertTable(schema *Schema, table *Table) (string, error)
ConvertTable converts a single YAML table definition to SQL CREATE TABLE statement
type SchemaDiff ¶
type SchemaDiff struct {
Changes []Change `json:"changes"`
HasChanges bool `json:"has_changes"`
IsDestructive bool `json:"is_destructive"`
}
SchemaDiff represents the complete difference between two schemas
type StateManager ¶
type StateManager struct {
// contains filtered or unexported fields
}
StateManager handles YAML schema state management
func NewStateManager ¶
func NewStateManager(verbose bool) *StateManager
NewStateManager creates a new YAML state manager
func (*StateManager) BackupSnapshot ¶
func (sm *StateManager) BackupSnapshot(migrationsDir string) error
BackupSnapshot creates a backup of the current snapshot
func (*StateManager) CompareSnapshots ¶
func (sm *StateManager) CompareSnapshots(schema1, schema2 *Schema) bool
CompareSnapshots compares two schema snapshots and returns whether they are equivalent
func (*StateManager) CreateInitialSnapshot ¶
func (sm *StateManager) CreateInitialSnapshot(databaseName string, migrationsDir string) error
CreateInitialSnapshot creates an initial empty schema snapshot
func (*StateManager) GetSnapshotPath ¶
func (sm *StateManager) GetSnapshotPath(migrationsDir string) string
GetSnapshotPath returns the path to the schema snapshot file
func (*StateManager) LoadSchemaSnapshot ¶
func (sm *StateManager) LoadSchemaSnapshot(migrationsDir string) (*Schema, error)
LoadSchemaSnapshot loads a YAML schema from the .schema_snapshot.yaml file
func (*StateManager) SaveSchemaSnapshot ¶
func (sm *StateManager) SaveSchemaSnapshot(schema *Schema, migrationsDir string) error
SaveSchemaSnapshot saves a YAML schema to the .schema_snapshot.yaml file
func (*StateManager) SchemaSnapshotExists ¶
func (sm *StateManager) SchemaSnapshotExists(migrationsDir string) bool
SchemaSnapshotExists checks if a schema snapshot file exists
func (*StateManager) ValidateSnapshot ¶
func (sm *StateManager) ValidateSnapshot(migrationsDir string) error
ValidateSnapshot validates that a snapshot file is valid YAML schema
type TypeMappings ¶
type TypeMappings = types.TypeMappings