Documentation
¶
Index ¶
- func RegisterCoreRules(registry *RuleRegistry) error
- type AdvancedColumnLifecycleRule
- func (r *AdvancedColumnLifecycleRule) Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
- func (r *AdvancedColumnLifecycleRule) CanApply(lifecycle *tracking.ObjectLifecycle) bool
- func (r *AdvancedColumnLifecycleRule) Risk() tracking.RiskLevel
- type ColumnChange
- type ColumnConstraint
- type ColumnConstraintInfo
- type ColumnEvolutionRule
- type ColumnLifecycleState
- type ColumnOperation
- type ColumnStatus
- type ColumnTransformation
- type ConditionalSchemaRule
- type ConditionalState
- type ConflictPolicy
- type ConsolidationEngine
- type ConsolidationRule
- type ConsolidationRuleEngine
- func (cre *ConsolidationRuleEngine) AddRule(rule ConsolidationRule)
- func (cre *ConsolidationRuleEngine) ApplyRules(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
- func (cre *ConsolidationRuleEngine) GetApplicableRules(lifecycle *tracking.ObjectLifecycle) []ConsolidationRule
- func (cre *ConsolidationRuleEngine) GetRegistry() *RuleRegistry
- func (cre *ConsolidationRuleEngine) Rules() []ConsolidationRule
- type ConstraintType
- type CreateAlterConsolidationRule
- func (r *CreateAlterConsolidationRule) Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
- func (r *CreateAlterConsolidationRule) CanApply(lifecycle *tracking.ObjectLifecycle) bool
- func (r *CreateAlterConsolidationRule) Risk() tracking.RiskLevel
- type DOBlockAlterTableRule
- type DOBlockEnumTypeRule
- type DropCreateCycleRule
- type EnumDeduplicationRule
- type ErrorRecoveryRule
- type ExternalDependencyFilterRule
- func (r *ExternalDependencyFilterRule) Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
- func (r *ExternalDependencyFilterRule) CanApply(lifecycle *tracking.ObjectLifecycle) bool
- func (r *ExternalDependencyFilterRule) Risk() tracking.RiskLevel
- type FunctionDeduplicationRule
- type MultipleCreateConsolidationRule
- func (r *MultipleCreateConsolidationRule) Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
- func (r *MultipleCreateConsolidationRule) CanApply(lifecycle *tracking.ObjectLifecycle) bool
- func (r *MultipleCreateConsolidationRule) Risk() tracking.RiskLevel
- type PublicationDeduplicationRule
- func (r *PublicationDeduplicationRule) Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
- func (r *PublicationDeduplicationRule) CanApply(lifecycle *tracking.ObjectLifecycle) bool
- func (r *PublicationDeduplicationRule) Risk() tracking.RiskLevel
- type RLSConsolidationRule
- type RegisteredRule
- type RegistryStats
- type RuleCategory
- type RuleMetadata
- type RuleRegistry
- func (r *RuleRegistry) Clear()
- func (r *RuleRegistry) DisableRule(name string) error
- func (r *RuleRegistry) EnableRule(name string) error
- func (r *RuleRegistry) GetAllRules() []*RegisteredRule
- func (r *RuleRegistry) GetApplicableRules(lifecycle *tracking.ObjectLifecycle) []*RegisteredRule
- func (r *RuleRegistry) GetEnabledRules() []*RegisteredRule
- func (r *RuleRegistry) GetRule(name string) (*RegisteredRule, error)
- func (r *RuleRegistry) GetRulesByCategory(category RuleCategory) []*RegisteredRule
- func (r *RuleRegistry) GetRulesByProvider(provider string) []*RegisteredRule
- func (r *RuleRegistry) GetRulesByTag(tag string) []*RegisteredRule
- func (r *RuleRegistry) GetStats() RegistryStats
- func (r *RuleRegistry) Register(rule ConsolidationRule, metadata RuleMetadata) error
- func (r *RuleRegistry) Unregister(name string) error
- type SeparateAlterRule
- type TransactionBoundaryRule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterCoreRules ¶
func RegisterCoreRules(registry *RuleRegistry) error
RegisterCoreRules registers all core consolidation rules with metadata
Types ¶
type AdvancedColumnLifecycleRule ¶
type AdvancedColumnLifecycleRule struct {
// contains filtered or unexported fields
}
AdvancedColumnLifecycleRule handles complex column evolution patterns with edge cases
func NewAdvancedColumnLifecycleRule ¶
func NewAdvancedColumnLifecycleRule() *AdvancedColumnLifecycleRule
NewAdvancedColumnLifecycleRule creates a new advanced column lifecycle rule
func (*AdvancedColumnLifecycleRule) Apply ¶
func (r *AdvancedColumnLifecycleRule) Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
Apply applies the advanced column lifecycle rule
func (*AdvancedColumnLifecycleRule) CanApply ¶
func (r *AdvancedColumnLifecycleRule) CanApply(lifecycle *tracking.ObjectLifecycle) bool
CanApply determines if this rule can be applied to the lifecycle
func (*AdvancedColumnLifecycleRule) Risk ¶
func (r *AdvancedColumnLifecycleRule) Risk() tracking.RiskLevel
Risk returns the risk level for advanced column lifecycle operations
type ColumnChange ¶
type ColumnChange struct {
Name string
Operation string // ADD, DROP, ALTER, RENAME
DataType string
Default string
NotNull bool
Order int
}
ColumnChange tracks a column modification operation
type ColumnConstraint ¶
type ColumnConstraint struct {
Type ConstraintType `json:"type"`
Name string `json:"name"`
Definition string `json:"definition"`
TableLevel bool `json:"table_level"`
}
ColumnConstraint represents a constraint on a column
type ColumnConstraintInfo ¶
type ColumnConstraintInfo struct {
Name string
Type ConstraintType
Definition string
AffectedColumns []string
TableLevel bool
}
ColumnConstraintInfo represents parsed constraint information for column lifecycle tracking
type ColumnEvolutionRule ¶
type ColumnEvolutionRule struct{}
ColumnEvolutionRule handles complex column lifecycle patterns
func (*ColumnEvolutionRule) Apply ¶
func (r *ColumnEvolutionRule) Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
Apply applies the consolidation rule to the given lifecycle
func (*ColumnEvolutionRule) CanApply ¶
func (r *ColumnEvolutionRule) CanApply(lifecycle *tracking.ObjectLifecycle) bool
CanApply checks if the rule can be applied to the given lifecycle
func (*ColumnEvolutionRule) Risk ¶
func (r *ColumnEvolutionRule) Risk() tracking.RiskLevel
Risk returns the risk level for this rule
type ColumnLifecycleState ¶
type ColumnLifecycleState struct {
Name string `json:"name"`
OriginalName string `json:"original_name"`
DataType string `json:"data_type"`
IsNullable bool `json:"is_nullable"`
DefaultValue string `json:"default_value"`
Constraints []ColumnConstraint `json:"constraints"`
Position int `json:"position"`
Transformations []ColumnTransformation `json:"transformations"`
Status ColumnStatus `json:"status"`
Dependencies []string `json:"dependencies"`
}
ColumnLifecycleState represents the complete state of a column through its lifecycle
type ColumnOperation ¶
type ColumnOperation string
ColumnOperation represents operations that can be performed on columns
const ( ColumnOpAdd ColumnOperation = "ADD" ColumnOpDrop ColumnOperation = "DROP" ColumnOpRename ColumnOperation = "RENAME" ColumnOpChangeType ColumnOperation = "CHANGE_TYPE" ColumnOpSetDefault ColumnOperation = "SET_DEFAULT" ColumnOpDropDefault ColumnOperation = "DROP_DEFAULT" ColumnOpSetNotNull ColumnOperation = "SET_NOT_NULL" ColumnOpDropNotNull ColumnOperation = "DROP_NOT_NULL" ColumnOpAddConstraint ColumnOperation = "ADD_CONSTRAINT" ColumnOpDropConstraint ColumnOperation = "DROP_CONSTRAINT" )
type ColumnStatus ¶
type ColumnStatus string
ColumnStatus represents the current status of a column
const ( ColumnStatusActive ColumnStatus = "ACTIVE" ColumnStatusDropped ColumnStatus = "DROPPED" ColumnStatusRenamed ColumnStatus = "RENAMED" ColumnStatusTransient ColumnStatus = "TRANSIENT" // Added and dropped in same lifecycle )
type ColumnTransformation ¶
type ColumnTransformation struct {
Operation ColumnOperation `json:"operation"`
OldValue string `json:"old_value"`
NewValue string `json:"new_value"`
AtSequence int `json:"at_sequence"`
SQL string `json:"sql"`
HasDataOps bool `json:"has_data_ops"`
}
ColumnTransformation tracks changes to a column
type ConditionalSchemaRule ¶
type ConditionalSchemaRule struct{}
ConditionalSchemaRule consolidates conditional schema operations (IF NOT EXISTS, CREATE OR REPLACE)
func (*ConditionalSchemaRule) Apply ¶
func (r *ConditionalSchemaRule) Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
Apply applies the consolidation rule to the given lifecycle
func (*ConditionalSchemaRule) CanApply ¶
func (r *ConditionalSchemaRule) CanApply(lifecycle *tracking.ObjectLifecycle) bool
CanApply checks if the rule can be applied to the given lifecycle
func (*ConditionalSchemaRule) Risk ¶
func (r *ConditionalSchemaRule) Risk() tracking.RiskLevel
Risk returns the risk level for this rule
type ConditionalState ¶
type ConditionalState struct {
ShouldExist bool
UseReplace bool
FinalSQL string
Dependencies []string
WasCreated bool
}
ConditionalState represents the final desired state after analyzing conditional operations
type ConflictPolicy ¶
type ConflictPolicy string
ConflictPolicy defines how to handle rule conflicts
const ( ConflictPolicyHighestPriority ConflictPolicy = "highest_priority" // Use rule with highest priority ConflictPolicyFirstRegistered ConflictPolicy = "first_registered" // Use first registered rule ConflictPolicyError ConflictPolicy = "error" // Return error on conflict )
type ConsolidationEngine ¶
type ConsolidationEngine interface {
GetTracker() *tracking.Tracker
GetConfig() *config.Config
GetSafetyLevel() string // Returns the current safety level (paranoid, conservative, standard, aggressive)
}
ConsolidationEngine interface for the engine that applies consolidation rules
type ConsolidationRule ¶
type ConsolidationRule interface {
CanApply(lifecycle *tracking.ObjectLifecycle) bool
Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
Risk() tracking.RiskLevel
}
ConsolidationRule interface for consolidation rules used by the squasher
type ConsolidationRuleEngine ¶
type ConsolidationRuleEngine struct {
// contains filtered or unexported fields
}
ConsolidationRuleEngine manages and applies consolidation rules
func NewConsolidationRuleEngine ¶
func NewConsolidationRuleEngine() *ConsolidationRuleEngine
NewConsolidationRuleEngine creates a new rule engine with all extracted rules
func (*ConsolidationRuleEngine) AddRule ¶
func (cre *ConsolidationRuleEngine) AddRule(rule ConsolidationRule)
AddRule adds an explicitly ordered rule to the engine.
func (*ConsolidationRuleEngine) ApplyRules ¶
func (cre *ConsolidationRuleEngine) ApplyRules(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
ApplyRules applies all applicable rules to a lifecycle If no rules apply, returns a default consolidation that preserves the original SQL
func (*ConsolidationRuleEngine) GetApplicableRules ¶
func (cre *ConsolidationRuleEngine) GetApplicableRules(lifecycle *tracking.ObjectLifecycle) []ConsolidationRule
GetApplicableRules returns all rules that can be applied to a lifecycle
func (*ConsolidationRuleEngine) GetRegistry ¶
func (cre *ConsolidationRuleEngine) GetRegistry() *RuleRegistry
GetRegistry returns the rule registry.
func (*ConsolidationRuleEngine) Rules ¶
func (cre *ConsolidationRuleEngine) Rules() []ConsolidationRule
Rules returns the explicitly ordered rules registered on this engine. The returned slice is a copy; mutating it does not affect the engine.
type ConstraintType ¶
type ConstraintType string
ConstraintType represents different types of column constraints
const ( ConstraintPrimaryKey ConstraintType = "PRIMARY_KEY" ConstraintForeignKey ConstraintType = "FOREIGN_KEY" ConstraintUnique ConstraintType = "UNIQUE" ConstraintCheck ConstraintType = "CHECK" ConstraintDefault ConstraintType = "DEFAULT" ConstraintNotNull ConstraintType = "NOT_NULL" )
type CreateAlterConsolidationRule ¶
type CreateAlterConsolidationRule struct{}
CreateAlterConsolidationRule consolidates CREATE statements followed by ALTER statements
func (*CreateAlterConsolidationRule) Apply ¶
func (r *CreateAlterConsolidationRule) Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
Apply applies the consolidation rule to the given lifecycle
func (*CreateAlterConsolidationRule) CanApply ¶
func (r *CreateAlterConsolidationRule) CanApply(lifecycle *tracking.ObjectLifecycle) bool
CanApply checks if the rule can be applied to the given lifecycle
func (*CreateAlterConsolidationRule) Risk ¶
func (r *CreateAlterConsolidationRule) Risk() tracking.RiskLevel
Risk returns the risk level for this rule
type DOBlockAlterTableRule ¶
type DOBlockAlterTableRule struct{}
DOBlockAlterTableRule extracts ALTER TABLE statements from DO blocks This allows ALTER statements wrapped in IF NOT EXISTS checks to be consolidated with their corresponding CREATE TABLE statements
func (*DOBlockAlterTableRule) Apply ¶
func (r *DOBlockAlterTableRule) Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
Apply applies the consolidation rule to the given lifecycle
func (*DOBlockAlterTableRule) CanApply ¶
func (r *DOBlockAlterTableRule) CanApply(lifecycle *tracking.ObjectLifecycle) bool
CanApply checks if the rule can be applied to the given lifecycle
func (*DOBlockAlterTableRule) Risk ¶
func (r *DOBlockAlterTableRule) Risk() tracking.RiskLevel
Risk returns the risk level for this rule
type DOBlockEnumTypeRule ¶
type DOBlockEnumTypeRule struct{}
DOBlockEnumTypeRule consolidates DO blocks that create ENUM types
func (*DOBlockEnumTypeRule) Apply ¶
func (r *DOBlockEnumTypeRule) Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
Apply applies the consolidation rule to the given lifecycle
func (*DOBlockEnumTypeRule) CanApply ¶
func (r *DOBlockEnumTypeRule) CanApply(lifecycle *tracking.ObjectLifecycle) bool
CanApply checks if the rule can be applied to the given lifecycle
func (*DOBlockEnumTypeRule) Risk ¶
func (r *DOBlockEnumTypeRule) Risk() tracking.RiskLevel
Risk returns the risk level for this rule
type DropCreateCycleRule ¶
type DropCreateCycleRule struct{}
DropCreateCycleRule handles DROP followed by CREATE consolidation This includes tables and views (DROP VIEW + CREATE VIEW → CREATE OR REPLACE VIEW)
func (*DropCreateCycleRule) Apply ¶
func (r *DropCreateCycleRule) Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
Apply applies the consolidation rule to the given lifecycle
func (*DropCreateCycleRule) CanApply ¶
func (r *DropCreateCycleRule) CanApply(lifecycle *tracking.ObjectLifecycle) bool
CanApply checks if the rule can be applied to the given lifecycle
func (*DropCreateCycleRule) Risk ¶
func (r *DropCreateCycleRule) Risk() tracking.RiskLevel
Risk returns the risk level for this rule
type EnumDeduplicationRule ¶
type EnumDeduplicationRule struct{}
EnumDeduplicationRule detects and resolves duplicate ENUM type definitions This handles cases where multiple ENUMs with similar names or conflicting values exist
func (*EnumDeduplicationRule) Apply ¶
func (r *EnumDeduplicationRule) Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
Apply applies the consolidation rule to the given lifecycle
func (*EnumDeduplicationRule) CanApply ¶
func (r *EnumDeduplicationRule) CanApply(lifecycle *tracking.ObjectLifecycle) bool
CanApply checks if the rule can be applied to the given lifecycle
func (*EnumDeduplicationRule) Risk ¶
func (r *EnumDeduplicationRule) Risk() tracking.RiskLevel
Risk returns the risk level for this rule
type ErrorRecoveryRule ¶
type ErrorRecoveryRule struct {
MaxRetries int
RecoveryMode string // "conservative", "aggressive", "fallback"
ValidateSQL bool
LogFailures bool
FailureMetrics map[string]int
// contains filtered or unexported fields
}
ErrorRecoveryRule provides enhanced error recovery and validation for consolidation failures
func NewErrorRecoveryRule ¶
func NewErrorRecoveryRule(maxRetries int, recoveryMode string, validateSQL bool) *ErrorRecoveryRule
NewErrorRecoveryRule creates a new error recovery rule with specified configuration
func (*ErrorRecoveryRule) Apply ¶
func (rule *ErrorRecoveryRule) Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
Apply implements the ConsolidationRule interface with error recovery
func (*ErrorRecoveryRule) CanApply ¶
func (rule *ErrorRecoveryRule) CanApply(lifecycle *tracking.ObjectLifecycle) bool
CanApply returns true for all objects to provide universal error recovery
func (*ErrorRecoveryRule) Risk ¶
func (rule *ErrorRecoveryRule) Risk() tracking.RiskLevel
Risk returns the risk level for error recovery rule
type ExternalDependencyFilterRule ¶
type ExternalDependencyFilterRule struct {
ExternalSchemas map[string]bool
ExternalTables map[string]bool
}
ExternalDependencyFilterRule filters out dependencies on external schemas
func NewExternalDependencyFilterRule ¶
func NewExternalDependencyFilterRule() *ExternalDependencyFilterRule
NewExternalDependencyFilterRule creates a new rule with default external dependencies
func (*ExternalDependencyFilterRule) Apply ¶
func (r *ExternalDependencyFilterRule) Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
Apply applies the consolidation rule to the given lifecycle
func (*ExternalDependencyFilterRule) CanApply ¶
func (r *ExternalDependencyFilterRule) CanApply(lifecycle *tracking.ObjectLifecycle) bool
CanApply checks if the rule can be applied to the given lifecycle
func (*ExternalDependencyFilterRule) Risk ¶
func (r *ExternalDependencyFilterRule) Risk() tracking.RiskLevel
Risk returns the risk level for this rule
type FunctionDeduplicationRule ¶
type FunctionDeduplicationRule struct{}
FunctionDeduplicationRule consolidates duplicate function definitions
func (*FunctionDeduplicationRule) Apply ¶
func (r *FunctionDeduplicationRule) Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
Apply applies the consolidation rule to the given lifecycle
func (*FunctionDeduplicationRule) CanApply ¶
func (r *FunctionDeduplicationRule) CanApply(lifecycle *tracking.ObjectLifecycle) bool
CanApply checks if the rule can be applied to the given lifecycle
func (*FunctionDeduplicationRule) Risk ¶
func (r *FunctionDeduplicationRule) Risk() tracking.RiskLevel
Risk returns the risk level for this rule
type MultipleCreateConsolidationRule ¶
type MultipleCreateConsolidationRule struct{}
MultipleCreateConsolidationRule handles multiple CREATE statements for the same object
func (*MultipleCreateConsolidationRule) Apply ¶
func (r *MultipleCreateConsolidationRule) Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
Apply applies the consolidation rule to the given lifecycle
func (*MultipleCreateConsolidationRule) CanApply ¶
func (r *MultipleCreateConsolidationRule) CanApply(lifecycle *tracking.ObjectLifecycle) bool
CanApply checks if the rule can be applied to the given lifecycle
func (*MultipleCreateConsolidationRule) Risk ¶
func (r *MultipleCreateConsolidationRule) Risk() tracking.RiskLevel
Risk returns the risk level for this rule
type PublicationDeduplicationRule ¶
type PublicationDeduplicationRule struct{}
PublicationDeduplicationRule removes duplicate ALTER PUBLICATION ADD TABLE statements This prevents "relation X is already member of publication Y" errors during deployment
func (*PublicationDeduplicationRule) Apply ¶
func (r *PublicationDeduplicationRule) Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
Apply applies the rule to deduplicate publication member additions
func (*PublicationDeduplicationRule) CanApply ¶
func (r *PublicationDeduplicationRule) CanApply(lifecycle *tracking.ObjectLifecycle) bool
CanApply checks if this rule can be applied to the given lifecycle
func (*PublicationDeduplicationRule) Risk ¶
func (r *PublicationDeduplicationRule) Risk() tracking.RiskLevel
Risk returns the risk level of this consolidation rule
type RLSConsolidationRule ¶
type RLSConsolidationRule struct{}
RLSConsolidationRule consolidates Row Level Security operations
func (*RLSConsolidationRule) Apply ¶
func (r *RLSConsolidationRule) Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
Apply applies the consolidation rule to the given lifecycle
func (*RLSConsolidationRule) CanApply ¶
func (r *RLSConsolidationRule) CanApply(lifecycle *tracking.ObjectLifecycle) bool
CanApply checks if the rule can be applied to the given lifecycle
func (*RLSConsolidationRule) Risk ¶
func (r *RLSConsolidationRule) Risk() tracking.RiskLevel
Risk returns the risk level for this rule
type RegisteredRule ¶
type RegisteredRule struct {
Rule ConsolidationRule
Metadata RuleMetadata
}
RegisteredRule wraps a ConsolidationRule with metadata
type RegistryStats ¶
type RegistryStats struct {
TotalRules int
EnabledRules int
DisabledRules int
RulesByCategory map[RuleCategory]int
RulesByProvider map[string]int
}
RegistryStats provides statistics about the registry
type RuleCategory ¶
type RuleCategory string
RuleCategory represents the category of a consolidation rule
const ( CategoryTableOps RuleCategory = "table_operations" // Table CREATE/ALTER consolidation CategoryFunctionOps RuleCategory = "function_operations" // Function deduplication CategoryDeadCode RuleCategory = "dead_code" // Dead code removal CategorySecurity RuleCategory = "security" // RLS, policies, auth CategoryOptimization RuleCategory = "optimization" // Performance optimizations CategoryExtension RuleCategory = "extension" // Extension-specific rules CategoryPluginAuth RuleCategory = "plugin_auth" // Plugin authentication patterns CategoryPluginORM RuleCategory = "plugin_orm" // ORM-specific patterns )
type RuleMetadata ¶
type RuleMetadata struct {
Name string // Unique rule name (e.g., "create_alter_consolidation")
Description string // Human-readable description
Category RuleCategory // Rule category for organization
Priority int // Execution priority (higher = executed first)
Provider string // Provider name (e.g., "core", "supabase", "clerk")
Tags []string // Tags for filtering (e.g., "aggressive", "safe", "auth")
Enabled bool // Whether rule is enabled
Version string // Rule version for compatibility
}
RuleMetadata provides descriptive information about a consolidation rule
type RuleRegistry ¶
type RuleRegistry struct {
// contains filtered or unexported fields
}
RuleRegistry manages dynamic rule registration with priorities and filtering
func GetRegistry ¶
func GetRegistry() *RuleRegistry
GetRegistry returns the global rule registry (singleton)
func NewRuleRegistry ¶
func NewRuleRegistry(conflictPolicy ConflictPolicy) *RuleRegistry
NewRuleRegistry creates a new rule registry
func (*RuleRegistry) Clear ¶
func (r *RuleRegistry) Clear()
Clear removes all rules from the registry
func (*RuleRegistry) DisableRule ¶
func (r *RuleRegistry) DisableRule(name string) error
DisableRule disables a rule
func (*RuleRegistry) EnableRule ¶
func (r *RuleRegistry) EnableRule(name string) error
EnableRule enables a rule
func (*RuleRegistry) GetAllRules ¶
func (r *RuleRegistry) GetAllRules() []*RegisteredRule
GetAllRules returns all registered rules sorted by priority (descending)
func (*RuleRegistry) GetApplicableRules ¶
func (r *RuleRegistry) GetApplicableRules(lifecycle *tracking.ObjectLifecycle) []*RegisteredRule
GetApplicableRules returns all enabled rules that can apply to a lifecycle
func (*RuleRegistry) GetEnabledRules ¶
func (r *RuleRegistry) GetEnabledRules() []*RegisteredRule
GetEnabledRules returns all enabled rules sorted by priority
func (*RuleRegistry) GetRule ¶
func (r *RuleRegistry) GetRule(name string) (*RegisteredRule, error)
GetRule retrieves a registered rule by name
func (*RuleRegistry) GetRulesByCategory ¶
func (r *RuleRegistry) GetRulesByCategory(category RuleCategory) []*RegisteredRule
GetRulesByCategory returns all rules in a category sorted by priority
func (*RuleRegistry) GetRulesByProvider ¶
func (r *RuleRegistry) GetRulesByProvider(provider string) []*RegisteredRule
GetRulesByProvider returns all rules from a provider sorted by priority
func (*RuleRegistry) GetRulesByTag ¶
func (r *RuleRegistry) GetRulesByTag(tag string) []*RegisteredRule
GetRulesByTag returns all rules with a specific tag
func (*RuleRegistry) GetStats ¶
func (r *RuleRegistry) GetStats() RegistryStats
GetStats returns registry statistics
func (*RuleRegistry) Register ¶
func (r *RuleRegistry) Register(rule ConsolidationRule, metadata RuleMetadata) error
Register registers a rule with metadata
func (*RuleRegistry) Unregister ¶
func (r *RuleRegistry) Unregister(name string) error
Unregister removes a rule from the registry
type SeparateAlterRule ¶
type SeparateAlterRule struct{}
SeparateAlterRule identifies ALTER statements that cannot be integrated into CREATE TABLE and must remain as separate statements. This includes RLS operations, column modifications, renames, owner changes, and schema changes.
This rule is critical for maintaining PostgreSQL execution order requirements: - RLS can only be enabled AFTER table exists - Column modifications require existing columns - Renames/ownership changes are administrative operations
func (*SeparateAlterRule) Apply ¶
func (r *SeparateAlterRule) Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
Apply separates ALTER statements that cannot be integrated into CREATE TABLE
func (*SeparateAlterRule) CanApply ¶
func (r *SeparateAlterRule) CanApply(lifecycle *tracking.ObjectLifecycle) bool
CanApply checks if the lifecycle has ALTER statements that must remain separate
func (*SeparateAlterRule) Risk ¶
func (r *SeparateAlterRule) Risk() tracking.RiskLevel
Risk returns the risk level for this rule
type TransactionBoundaryRule ¶
type TransactionBoundaryRule struct{}
TransactionBoundaryRule optimizes transaction boundaries for better performance
func (*TransactionBoundaryRule) Apply ¶
func (r *TransactionBoundaryRule) Apply(lifecycle *tracking.ObjectLifecycle, engine ConsolidationEngine) (*tracking.ConsolidationResult, error)
Apply applies the consolidation rule to the given lifecycle Delegates to squasher.TransactionPlanner for transaction grouping (single source of truth)
func (*TransactionBoundaryRule) CanApply ¶
func (r *TransactionBoundaryRule) CanApply(lifecycle *tracking.ObjectLifecycle) bool
CanApply checks if the rule can be applied to the given lifecycle
func (*TransactionBoundaryRule) Risk ¶
func (r *TransactionBoundaryRule) Risk() tracking.RiskLevel
Risk returns the risk level for this rule
Source Files
¶
- advanced_column_lifecycle_rule.go
- column_evolution_rule.go
- conditional_schema_rule.go
- create_alter_rule.go
- do_block_alter_table_rule.go
- do_block_enum_rule.go
- drop_create_rule.go
- enum_dedup_rule.go
- error_recovery_rule.go
- external_dependency_rule.go
- function_dedup_rule.go
- multiple_create_rule.go
- publications.go
- registry.go
- rls_consolidation_rule.go
- rule.go
- separate_alter_rule.go
- transaction_rule.go