Documentation
¶
Index ¶
- func ApplyDDL(catalog *catalog.Catalog, stmt string, migrationFile string, ...) error
- type AlterTableParser
- type AlterTableStatement
- type CreateEnumParser
- type CreateEnumStatement
- type CreateIndexParser
- type CreateIndexStatement
- type CreateSchemaParser
- type CreateSchemaStatement
- type CreateTableParser
- type CreateTableStatement
- type DDLParser
- type DDLStatement
- type DDLVisitor
- type DropEnumParser
- type DropEnumStatement
- type DropIndexParser
- type DropIndexStatement
- type DropSchemaParser
- type DropSchemaStatement
- type DropTableParser
- type DropTableStatement
- type EnumVisitor
- type IndexVisitor
- type SchemaVisitor
- type Statement
- type StatementType
- type TableVisitor
- type UnknownStatement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AlterTableParser ¶
type AlterTableParser struct {
// contains filtered or unexported fields
}
AlterTableParser handles ALTER TABLE statements
func NewAlterTableParser ¶
func NewAlterTableParser() *AlterTableParser
func (*AlterTableParser) Parse ¶
func (p *AlterTableParser) Parse( sql, migrationFile string, databaseType string, ) (*AlterTableStatement, error)
type AlterTableStatement ¶
type AlterTableStatement struct {
Raw string
SchemaName string
TableName string
AlterOperation string
ColumnName string
NewColumnName string
NewTableName string
ColumnDef *catalog.Column
ColumnChanges map[string]any
Operations []string
}
func (*AlterTableStatement) Accept ¶
func (s *AlterTableStatement) Accept(visitor DDLVisitor) error
func (*AlterTableStatement) GetRaw ¶
func (s *AlterTableStatement) GetRaw() string
func (*AlterTableStatement) GetType ¶
func (s *AlterTableStatement) GetType() StatementType
type CreateEnumParser ¶
type CreateEnumParser struct{}
CreateEnumParser handles CREATE TYPE (enum) statements
func NewCreateEnumParser ¶
func NewCreateEnumParser() *CreateEnumParser
func (*CreateEnumParser) Parse ¶
func (p *CreateEnumParser) Parse(sql string) (*CreateEnumStatement, error)
type CreateEnumStatement ¶
type CreateEnumStatement struct {
Raw string
SchemaName string
EnumName string
EnumDef *catalog.Enum
}
func (*CreateEnumStatement) Accept ¶
func (s *CreateEnumStatement) Accept(visitor DDLVisitor) error
func (*CreateEnumStatement) GetRaw ¶
func (s *CreateEnumStatement) GetRaw() string
func (*CreateEnumStatement) GetType ¶
func (s *CreateEnumStatement) GetType() StatementType
type CreateIndexParser ¶
type CreateIndexParser struct{}
CreateIndexParser handles CREATE INDEX statements
func NewCreateIndexParser ¶
func NewCreateIndexParser() *CreateIndexParser
func (*CreateIndexParser) Parse ¶
func (p *CreateIndexParser) Parse(sql string) (*CreateIndexStatement, error)
type CreateIndexStatement ¶
type CreateIndexStatement struct {
Raw string
}
func (*CreateIndexStatement) Accept ¶
func (s *CreateIndexStatement) Accept(visitor DDLVisitor) error
func (*CreateIndexStatement) GetRaw ¶
func (s *CreateIndexStatement) GetRaw() string
func (*CreateIndexStatement) GetType ¶
func (s *CreateIndexStatement) GetType() StatementType
type CreateSchemaParser ¶
type CreateSchemaParser struct{}
CreateSchemaParser handles CREATE SCHEMA statements
func NewCreateSchemaParser ¶
func NewCreateSchemaParser() *CreateSchemaParser
func (*CreateSchemaParser) Parse ¶
func (p *CreateSchemaParser) Parse(sql string) (*CreateSchemaStatement, error)
type CreateSchemaStatement ¶
func (*CreateSchemaStatement) Accept ¶
func (s *CreateSchemaStatement) Accept(visitor DDLVisitor) error
func (*CreateSchemaStatement) GetRaw ¶
func (s *CreateSchemaStatement) GetRaw() string
func (*CreateSchemaStatement) GetType ¶
func (s *CreateSchemaStatement) GetType() StatementType
type CreateTableParser ¶
type CreateTableParser struct{}
CreateTableParser handles CREATE TABLE statements
func NewCreateTableParser ¶
func NewCreateTableParser() *CreateTableParser
func (*CreateTableParser) Parse ¶
func (p *CreateTableParser) Parse( sql, migrationFile string, databaseType string, ) (*CreateTableStatement, error)
type CreateTableStatement ¶
type CreateTableStatement struct {
Raw string
SchemaName string
TableName string
IfNotExists bool
Columns []*catalog.Column
}
Statement implementations
func (*CreateTableStatement) Accept ¶
func (s *CreateTableStatement) Accept(visitor DDLVisitor) error
func (*CreateTableStatement) GetRaw ¶
func (s *CreateTableStatement) GetRaw() string
func (*CreateTableStatement) GetType ¶
func (s *CreateTableStatement) GetType() StatementType
type DDLParser ¶
type DDLParser struct {
// contains filtered or unexported fields
}
NewDDLParser creates a parser using the visitor pattern
func NewDDLParser ¶
func NewDDLParser() *DDLParser
type DDLStatement ¶
type DDLStatement struct {
Type StatementType
SchemaName string
TableName string
ColumnDef *catalog.Column
Operation string
Raw string
IndexDef *catalog.Index
EnumDef *catalog.Enum
IfNotExists bool
AlterOperation string
ColumnName string
NewColumnName string
NewTableName string
ColumnChanges map[string]any
}
DDLStatement provides backward compatibility for existing code TODO: Remove this once all code is updated to use the new visitor pattern
func ParseDDLStatement ¶
func ParseDDLStatement(sql, migrationFile string, databaseType string) (*DDLStatement, error)
ParseDDLStatement provides backward compatibility TODO: Remove this once all code is updated to use the new visitor pattern
type DDLVisitor ¶
type DDLVisitor interface {
TableVisitor
IndexVisitor
SchemaVisitor
EnumVisitor
}
DDLVisitor combines all DDL visitor interfaces
type DropEnumParser ¶
type DropEnumParser struct{}
DropEnumParser handles DROP TYPE (enum) statements
func NewDropEnumParser ¶
func NewDropEnumParser() *DropEnumParser
func (*DropEnumParser) Parse ¶
func (p *DropEnumParser) Parse(sql string) (*DropEnumStatement, error)
type DropEnumStatement ¶
func (*DropEnumStatement) Accept ¶
func (s *DropEnumStatement) Accept(visitor DDLVisitor) error
func (*DropEnumStatement) GetRaw ¶
func (s *DropEnumStatement) GetRaw() string
func (*DropEnumStatement) GetType ¶
func (s *DropEnumStatement) GetType() StatementType
type DropIndexParser ¶
type DropIndexParser struct{}
DropIndexParser handles DROP INDEX statements
func NewDropIndexParser ¶
func NewDropIndexParser() *DropIndexParser
func (*DropIndexParser) Parse ¶
func (p *DropIndexParser) Parse(sql string) (*DropIndexStatement, error)
type DropIndexStatement ¶
type DropIndexStatement struct {
Raw string
}
func (*DropIndexStatement) Accept ¶
func (s *DropIndexStatement) Accept(visitor DDLVisitor) error
func (*DropIndexStatement) GetRaw ¶
func (s *DropIndexStatement) GetRaw() string
func (*DropIndexStatement) GetType ¶
func (s *DropIndexStatement) GetType() StatementType
type DropSchemaParser ¶
type DropSchemaParser struct{}
DropSchemaParser handles DROP SCHEMA statements
func NewDropSchemaParser ¶
func NewDropSchemaParser() *DropSchemaParser
func (*DropSchemaParser) Parse ¶
func (p *DropSchemaParser) Parse(sql string) (*DropSchemaStatement, error)
type DropSchemaStatement ¶
func (*DropSchemaStatement) Accept ¶
func (s *DropSchemaStatement) Accept(visitor DDLVisitor) error
func (*DropSchemaStatement) GetRaw ¶
func (s *DropSchemaStatement) GetRaw() string
func (*DropSchemaStatement) GetType ¶
func (s *DropSchemaStatement) GetType() StatementType
type DropTableParser ¶
type DropTableParser struct{}
DropTableParser handles DROP TABLE statements
func NewDropTableParser ¶
func NewDropTableParser() *DropTableParser
func (*DropTableParser) Parse ¶
func (p *DropTableParser) Parse(sql string) (*DropTableStatement, error)
type DropTableStatement ¶
func (*DropTableStatement) Accept ¶
func (s *DropTableStatement) Accept(visitor DDLVisitor) error
func (*DropTableStatement) GetRaw ¶
func (s *DropTableStatement) GetRaw() string
func (*DropTableStatement) GetType ¶
func (s *DropTableStatement) GetType() StatementType
type EnumVisitor ¶
type EnumVisitor interface {
VisitCreateEnum(stmt *CreateEnumStatement) error
VisitDropEnum(stmt *DropEnumStatement) error
}
EnumVisitor handles enum-related DDL operations
type IndexVisitor ¶
type IndexVisitor interface {
VisitCreateIndex(stmt *CreateIndexStatement) error
VisitDropIndex(stmt *DropIndexStatement) error
}
IndexVisitor handles index-related DDL operations
type SchemaVisitor ¶
type SchemaVisitor interface {
VisitCreateSchema(stmt *CreateSchemaStatement) error
VisitDropSchema(stmt *DropSchemaStatement) error
}
SchemaVisitor handles schema-related DDL operations
type Statement ¶
type Statement interface {
Accept(visitor DDLVisitor) error
GetRaw() string
GetType() StatementType
}
Base statement interfaces
type StatementType ¶
type StatementType int
StatementType represents the type of DDL statement
const ( CreateTable StatementType = iota AlterTable DropTable CreateIndex DropIndex CreateSchema DropSchema CreateEnum DropEnum Unknown )
type TableVisitor ¶
type TableVisitor interface {
VisitCreateTable(stmt *CreateTableStatement) error
VisitAlterTable(stmt *AlterTableStatement) error
VisitDropTable(stmt *DropTableStatement) error
}
TableVisitor handles table-related DDL operations
type UnknownStatement ¶
type UnknownStatement struct {
Raw string
}
func (*UnknownStatement) Accept ¶
func (s *UnknownStatement) Accept(visitor DDLVisitor) error
func (*UnknownStatement) GetRaw ¶
func (s *UnknownStatement) GetRaw() string
func (*UnknownStatement) GetType ¶
func (s *UnknownStatement) GetType() StatementType