Documentation
¶
Index ¶
- Constants
- func ChunkSDLText(sdlText string) (*schema.SDLChunks, error)
- func ExtractFunctionSignature(ctx *parser.CreatefunctionstmtContext, funcName string) string
- func GetDatabaseDefinition(ctx schema.GetDefinitionContext, metadata *storepb.DatabaseSchemaMetadata) (string, error)
- func GetDatabaseMetadata(schemaText string) (*storepb.DatabaseSchemaMetadata, error)
- func GetFunctionDefinition(schema string, function *storepb.FunctionMetadata) (string, error)
- func GetMaterializedViewDefinition(schema string, view *storepb.MaterializedViewMetadata) (string, error)
- func GetMultiFileDatabaseDefinition(ctx schema.GetDefinitionContext, metadata *storepb.DatabaseSchemaMetadata) (*schema.MultiFileSchemaResult, error)
- func GetSDLDiff(currentSDLText, previousUserSDLText string, ...) (*schema.MetadataDiff, error)
- func GetSchemaDefinition(schema *storepb.SchemaMetadata) (string, error)
- func GetSchemaSDLDefinition(schema *storepb.SchemaMetadata) (string, error)
- func GetSequenceDefinition(schema string, sequence *storepb.SequenceMetadata) (string, error)
- func GetTableDefinition(schema string, table *storepb.TableMetadata, ...) (string, error)
- func GetViewDefinition(schema string, view *storepb.ViewMetadata) (string, error)
- func NormalizePostgreSQLType(typeName string) string
- func WalkThrough(d *model.DatabaseMetadata, ast []base.AST) *storepb.Advice
- type CheckConstraintDefWithAST
- type ColumnDefWithAST
- type ColumnDefWithASTOrdered
- type CreateOrReplaceTriggerVisitor
- type CreateOrReplaceVisitor
- type ExcludeConstraintDefWithAST
- type ForeignKeyDefWithAST
- type FunctionBodyVisitor
- type FunctionChangeType
- type FunctionParameter
- type FunctionSignature
- type FunctionSignatureVisitor
- type IndexDefWithAST
- type IndexDefinition
- type PostgreSQLFunctionComparer
- type PostgreSQLIndexComparer
- type PostgreSQLViewComparer
- type PrimaryKeyDefWithAST
- type SemanticTokens
- type UniqueKeyDefWithAST
Constants ¶
const (
// PublicSchemaName is the default schema name for PostgreSQL.
PublicSchemaName = "public"
)
Variables ¶
This section is empty.
Functions ¶
func ChunkSDLText ¶
ChunkSDLText parses SDL text and extracts chunks for each database object.
func ExtractFunctionSignature ¶
func ExtractFunctionSignature(ctx *parser.CreatefunctionstmtContext, funcName string) string
ExtractFunctionSignature extracts the function signature with parameter types
func GetDatabaseDefinition ¶
func GetDatabaseDefinition(ctx schema.GetDefinitionContext, metadata *storepb.DatabaseSchemaMetadata) (string, error)
func GetDatabaseMetadata ¶
func GetDatabaseMetadata(schemaText string) (*storepb.DatabaseSchemaMetadata, error)
GetDatabaseMetadata parses the SQL schema text and returns the database metadata.
func GetFunctionDefinition ¶
func GetFunctionDefinition(schema string, function *storepb.FunctionMetadata) (string, error)
func GetMaterializedViewDefinition ¶
func GetMaterializedViewDefinition(schema string, view *storepb.MaterializedViewMetadata) (string, error)
func GetMultiFileDatabaseDefinition ¶
func GetMultiFileDatabaseDefinition(ctx schema.GetDefinitionContext, metadata *storepb.DatabaseSchemaMetadata) (*schema.MultiFileSchemaResult, error)
GetMultiFileDatabaseDefinition generates multi-file SDL schema for PostgreSQL.
func GetSDLDiff ¶
func GetSDLDiff(currentSDLText, previousUserSDLText string, currentSchema, previousSchema *model.DatabaseMetadata) (*schema.MetadataDiff, error)
func GetSchemaDefinition ¶
func GetSchemaDefinition(schema *storepb.SchemaMetadata) (string, error)
func GetSchemaSDLDefinition ¶
func GetSchemaSDLDefinition(schema *storepb.SchemaMetadata) (string, error)
func GetSequenceDefinition ¶
func GetSequenceDefinition(schema string, sequence *storepb.SequenceMetadata) (string, error)
func GetTableDefinition ¶
func GetTableDefinition(schema string, table *storepb.TableMetadata, sequences []*storepb.SequenceMetadata) (string, error)
func GetViewDefinition ¶
func GetViewDefinition(schema string, view *storepb.ViewMetadata) (string, error)
func NormalizePostgreSQLType ¶
normalizePostgreSQLType normalizes PostgreSQL type names to match sync.go output
func WalkThrough ¶
WalkThrough walks through the PostgreSQL ANTLR parse tree and builds catalog metadata.
Types ¶
type CheckConstraintDefWithAST ¶
type CheckConstraintDefWithAST struct {
Name string
ASTNode parser.ITableconstraintContext
}
CheckConstraintDefWithAST holds check constraint definition with its AST node for text comparison
type ColumnDefWithAST ¶
type ColumnDefWithAST struct {
Name string
ASTNode parser.IColumnDefContext
}
ColumnDefWithAST holds a column definition AST node with its name for efficient lookup
type ColumnDefWithASTOrdered ¶
type ColumnDefWithASTOrdered struct {
Map map[string]*ColumnDefWithAST
Order []string // Column names in the order they appear in the AST
}
ColumnDefWithASTOrdered holds column definitions in AST order for deterministic processing
type CreateOrReplaceTriggerVisitor ¶
type CreateOrReplaceTriggerVisitor struct {
*pgparser.BasePostgreSQLParserVisitor
// contains filtered or unexported fields
}
CreateOrReplaceTriggerVisitor visits the parse tree and modifies CREATE TRIGGER to CREATE OR REPLACE TRIGGER
type CreateOrReplaceVisitor ¶
type CreateOrReplaceVisitor struct {
*pgparser.BasePostgreSQLParserVisitor
// contains filtered or unexported fields
}
CreateOrReplaceVisitor visits the parse tree and modifies CREATE FUNCTION to CREATE OR REPLACE FUNCTION
type ExcludeConstraintDefWithAST ¶
type ExcludeConstraintDefWithAST struct {
Name string
ASTNode parser.ITableconstraintContext
}
ExcludeConstraintDefWithAST holds EXCLUDE constraint definition with its AST node for text comparison
type ForeignKeyDefWithAST ¶
type ForeignKeyDefWithAST struct {
Name string
ASTNode parser.ITableconstraintContext
}
ForeignKeyDefWithAST holds foreign key constraint definition with its AST node for text comparison
type FunctionBodyVisitor ¶
type FunctionBodyVisitor struct {
*pgparser.BasePostgreSQLParserVisitor
}
FunctionBodyVisitor extracts function body from ANTLR parse tree.
type FunctionChangeType ¶
type FunctionChangeType int
FunctionChangeType represents the type of change detected in a function.
const ( FunctionChangeNone FunctionChangeType = iota FunctionChangeBodyOnly FunctionChangeSignature FunctionChangeAttributes FunctionChangeBoth // Both signature and body changed )
type FunctionParameter ¶
type FunctionParameter struct {
Mode string // IN, OUT, INOUT, VARIADIC
Name string
DataType string
Default string
}
FunctionParameter represents a function parameter.
type FunctionSignature ¶
type FunctionSignature struct {
Name string
Parameters []FunctionParameter
ReturnType string
Language string
Volatility string // VOLATILE, STABLE, IMMUTABLE
Security string // DEFINER, INVOKER
Parallel string // UNSAFE, RESTRICTED, SAFE
Cost string
Rows string
Leakproof bool
Strict bool
}
FunctionSignature represents the parsed signature of a PostgreSQL function.
type FunctionSignatureVisitor ¶
type FunctionSignatureVisitor struct {
*pgparser.BasePostgreSQLParserVisitor
}
FunctionSignatureVisitor extracts function signature information from ANTLR parse tree.
type IndexDefWithAST ¶
type IndexDefWithAST struct {
Name string
ASTNode parser.ITableconstraintContext
}
IndexDefWithAST holds index/unique constraint definition with its AST node for text comparison
type IndexDefinition ¶
type IndexDefinition struct {
IndexName string
TableName string
Unique bool
Method string // btree, gin, gist, etc.
Expressions []string
WhereClause string
}
IndexDefinition represents the parsed structure of a CREATE INDEX statement.
type PostgreSQLFunctionComparer ¶
type PostgreSQLFunctionComparer struct {
schema.DefaultFunctionComparer
}
PostgreSQLFunctionComparer provides PostgreSQL-specific function comparison logic.
func (*PostgreSQLFunctionComparer) CompareDetailed ¶
func (*PostgreSQLFunctionComparer) CompareDetailed(oldFunc, newFunc *storepb.FunctionMetadata) (*schema.FunctionComparisonResult, error)
CompareDetailed compares two functions with PostgreSQL-specific logic using ANTLR parsing.
func (*PostgreSQLFunctionComparer) Equal ¶
func (c *PostgreSQLFunctionComparer) Equal(oldFunc, newFunc *storepb.FunctionMetadata) bool
Equal compares two functions for equality (implements the interface expected by the schema differ).
type PostgreSQLIndexComparer ¶
type PostgreSQLIndexComparer struct{}
PostgreSQLIndexComparer provides PostgreSQL-specific index comparison logic.
func (*PostgreSQLIndexComparer) CompareIndexWhereConditions ¶
func (c *PostgreSQLIndexComparer) CompareIndexWhereConditions(def1, def2 string) bool
CompareIndexWhereConditions compares WHERE conditions from PostgreSQL index definitions using AST parsing.
func (*PostgreSQLIndexComparer) ExtractWhereClauseFromIndexDef ¶
func (*PostgreSQLIndexComparer) ExtractWhereClauseFromIndexDef(definition string) string
ExtractWhereClauseFromIndexDef extracts the WHERE clause from a CREATE INDEX statement using ANTLR AST parsing.
func (*PostgreSQLIndexComparer) ParseIndexDefinition ¶
func (c *PostgreSQLIndexComparer) ParseIndexDefinition(definition string) (*IndexDefinition, error)
ParseIndexDefinition parses a complete CREATE INDEX statement and returns structured information.
type PostgreSQLViewComparer ¶
type PostgreSQLViewComparer struct {
schema.DefaultViewComparer
}
PostgreSQLViewComparer provides PostgreSQL-specific view comparison logic.
func (*PostgreSQLViewComparer) CompareMaterializedView ¶
func (c *PostgreSQLViewComparer) CompareMaterializedView(oldMV, newMV *storepb.MaterializedViewMetadata) ([]schema.MaterializedViewChange, error)
CompareMaterializedView compares two materialized views with PostgreSQL-specific logic.
func (*PostgreSQLViewComparer) CompareView ¶
func (c *PostgreSQLViewComparer) CompareView(oldView, newView *storepb.ViewMetadata) ([]schema.ViewChange, error)
CompareView compares two views with PostgreSQL-specific logic using AST semantic analysis.
type PrimaryKeyDefWithAST ¶
type PrimaryKeyDefWithAST struct {
Name string
ASTNode parser.ITableconstraintContext
}
PrimaryKeyDefWithAST represents a primary key constraint definition with its AST node
type SemanticTokens ¶
type SemanticTokens struct {
SelectItems []string // normalized select items
TableRefs []string // normalized table references
JoinClauses []string // normalized join clauses
WhereClause string // normalized where condition
GroupByItems []string // normalized group by items
OrderByItems []string // normalized order by items
}
SemanticTokens represents the semantic structure of a SQL query.
type UniqueKeyDefWithAST ¶
type UniqueKeyDefWithAST struct {
Name string
ASTNode parser.ITableconstraintContext
}
UniqueKeyDefWithAST represents a unique key constraint definition with its AST node
Source Files
¶
- function_comparer.go
- generate_migration.go
- get_database_definition.go
- get_database_metadata.go
- get_sdl_diff.go
- index_comparer.go
- sdl_chunk.go
- sdl_comment.go
- sdl_common.go
- sdl_constraint.go
- sdl_enum.go
- sdl_event_trigger.go
- sdl_extension.go
- sdl_function.go
- sdl_index.go
- sdl_materialized_view.go
- sdl_schema.go
- sdl_sequence.go
- sdl_table.go
- sdl_view.go
- trigger_differ.go
- view_comparer.go
- walk_through.go