config

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const ValidationDSNEnv = "CAPYSQUASH_VALIDATION_DSN"

ValidationDSNEnv names the environment variable holding the validation database connection string (the same one validate-external reads with --dsn-env CAPYSQUASH_VALIDATION_DSN).

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth0Config

type Auth0Config struct {
	Enabled       bool     `json:"enabled"`
	Domain        string   `json:"domain"`
	CustomClaims  []string `json:"custom_claims"`
	RoleClaimPath string   `json:"role_claim_path"`
}

type ClerkConfig

type ClerkConfig struct {
	Enabled               bool   `json:"enabled"`
	JWTVersion            string `json:"jwt_version"`
	OrganizationSupport   bool   `json:"organization_support"`
	PublicMetadataSupport bool   `json:"public_metadata_support"`
}

type Config

type Config struct {
	SafetyLevel string `json:"safety_level"`
	ProdDBDSN   string `json:"prod_db_dsn"`
	// ValidationDSN is an empty, disposable database the paranoid level
	// applies the squashed baseline to, so its catalog can be compared with
	// production's. Defaults to CAPYSQUASH_VALIDATION_DSN.
	ValidationDSN          string                   `json:"validation_dsn,omitempty"`
	Output                 OutputConfig             `json:"output"`
	Rules                  RulesConfig              `json:"rules"`
	ExcludePatterns        []string                 `json:"exclude_patterns"`
	IncludeSchemas         []string                 `json:"include_schemas"`
	Performance            PerformanceConfig        `json:"performance"`
	ModernFeatures         ModernFeaturesConfig     `json:"modern_features"`
	ConflictResolution     ConflictResolutionConfig `json:"conflict_resolution"`
	PostgreSQLFeatures     PostgreSQLFeaturesConfig `json:"postgresql_features"`
	ThirdPartyIntegrations ThirdPartyConfig         `json:"third_party_integrations"`
	Plugins                PluginSettings           `json:"plugins"`           // Plugin system configuration
	Validation             ValidationConfig         `json:"validation"`        // Docker validation configuration
	StaticValidation       StaticValidatorConfig    `json:"static_validation"` // Static analysis rules configuration
}

func DefaultConfig

func DefaultConfig() *Config

func LoadConfig

func LoadConfig(configPath string) (*Config, error)

func (*Config) SaveToFile

func (c *Config) SaveToFile(path string) error

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the config values are valid

type ConfigValidationError

type ConfigValidationError struct {
	Path   string
	Errors []string
}

ConfigValidationError represents config validation errors with helpful messages

func (*ConfigValidationError) Error

func (e *ConfigValidationError) Error() string

type ConflictResolutionConfig

type ConflictResolutionConfig struct {
	EnablePrioritySystem  bool   `json:"enable_priority_system"`
	StrictModeEnabled     bool   `json:"strict_mode_enabled"`
	AllowOverlappingRules bool   `json:"allow_overlapping_rules"`
	ConflictLogLevel      string `json:"conflict_log_level"`
}

type FunctionRulesConfig

type FunctionRulesConfig struct {
	RemoveDuplicateDefinitions bool `json:"remove_duplicate_definitions"`
	PreserveSignatureChanges   bool `json:"preserve_signature_changes"`
}

type GenericJSONError

type GenericJSONError struct {
	Path    string
	Message string
}

GenericJSONError represents other JSON parsing errors

func (*GenericJSONError) Error

func (e *GenericJSONError) Error() string

type IndexRulesConfig

type IndexRulesConfig struct {
	ConsolidateRecreations    bool `json:"consolidate_recreations"`
	PreserveUniqueConstraints bool `json:"preserve_unique_constraints"`
}

type JSONSyntaxError

type JSONSyntaxError struct {
	Path    string
	Line    int
	Column  int
	Context string
	Message string
}

JSONSyntaxError represents a JSON syntax error with helpful context

func (*JSONSyntaxError) Error

func (e *JSONSyntaxError) Error() string

type JSONTypeError

type JSONTypeError struct {
	Path     string
	Line     int
	Column   int
	Context  string
	Field    string
	Expected string
	Got      string
}

JSONTypeError represents a JSON type mismatch error

func (*JSONTypeError) Error

func (e *JSONTypeError) Error() string

type ModernFeaturesConfig

type ModernFeaturesConfig struct {
	EnableVectorSupport    bool `json:"enable_vector_support"`
	EnableGeneratedColumns bool `json:"enable_generated_columns"`
	EnableEventSourcing    bool `json:"enable_event_sourcing"`
	EnableMergeStatements  bool `json:"enable_merge_statements"`
	EnableMultirangeTypes  bool `json:"enable_multirange_types"`
	EnableAdvancedRLS      bool `json:"enable_advanced_rls"`
}

type NextAuthConfig

type NextAuthConfig struct {
	Enabled         bool     `json:"enabled"`
	SessionStrategy string   `json:"session_strategy"`
	DatabaseTables  []string `json:"database_tables"`
}

type OutputConfig

type OutputConfig struct {
	Format                   string `json:"format"`
	PreserveComments         bool   `json:"preserve_comments"`
	AddConsolidationComments bool   `json:"add_consolidation_comments"`
	FileNaming               string `json:"file_naming"`
	Directory                string `json:"directory"`
}

type PerformanceConfig

type PerformanceConfig struct {
	StreamingThresholdMB int  `json:"streaming_threshold_mb"`
	ParallelProcessing   bool `json:"parallel_processing"`
	ShowProgress         bool `json:"show_progress"`
}

type PlanetScaleConfig

type PlanetScaleConfig struct {
	Enabled                bool `json:"enabled"`
	DisableForeignKeys     bool `json:"disable_foreign_keys"`
	OptimizeForReplication bool `json:"optimize_for_replication"`
}

type PluginSettings

type PluginSettings struct {
	AutoDetect      bool     `json:"auto_detect"`      // Automatically detect and enable plugins (default: true)
	EnabledPlugins  []string `json:"enabled_plugins"`  // Explicitly enabled plugins (empty = auto-detect all)
	DisabledPlugins []string `json:"disabled_plugins"` // Explicitly disabled plugins
	Verbose         bool     `json:"verbose"`          // Log plugin activity (default: false)
}

PluginSettings configures the plugin system behavior

type PostgreSQLFeaturesConfig

type PostgreSQLFeaturesConfig struct {
	TargetVersion          string   `json:"target_version"`
	EnabledExtensions      []string `json:"enabled_extensions"`
	OptimizeForPerformance bool     `json:"optimize_for_performance"`
	UseModernSyntax        bool     `json:"use_modern_syntax"`
	ValidateCompatibility  bool     `json:"validate_compatibility"`
	UseASTAnalyzer         bool     `json:"use_ast_analyzer"` // Use AST-based analyzer instead of regex (default: true)
}

type RulesConfig

type RulesConfig struct {
	TableOperations    TableRulesConfig    `json:"table_operations"`
	IndexOperations    IndexRulesConfig    `json:"index_operations"`
	FunctionOperations FunctionRulesConfig `json:"function_operations"`

	// Overrides force-enables (true) or force-disables (false) specific named
	// consolidation rules relative to the safety-level baseline. Keys are rule
	// names as registered in the consolidation rule registry (e.g.
	// "create_alter_consolidation"). Unknown rule names are rejected when the
	// engine is constructed. A nil/empty map applies the baseline unchanged.
	Overrides map[string]bool `json:"overrides,omitempty"`
}

type StaticValidatorConfig

type StaticValidatorConfig struct {
	// EnabledRules is a list of rule codes to enable.
	// If empty or nil, all registered rules are enabled.
	EnabledRules []string `json:"enabled_rules" yaml:"enabled_rules" toml:"enabled_rules"`

	// RuleOptions allows passing custom configuration to specific rules.
	// Key is the rule code.
	RuleOptions map[string]map[string]any `json:"rule_options" yaml:"rule_options" toml:"rule_options"`

	// TreatWarningsAsErrors causes all violations to be reported as errors
	TreatWarningsAsErrors bool `json:"treat_warnings_as_errors" yaml:"treat_warnings_as_errors" toml:"treat_warnings_as_errors"`

	// Strict makes a squash abort when pre-flight validation of the input
	// migrations reports any violation or cannot run (squash --strict).
	// Without it, pre-flight findings are reported as warnings.
	Strict bool `json:"strict" yaml:"strict" toml:"strict"`
}

StaticValidatorConfig configures the static validator

func DefaultStaticValidatorConfig

func DefaultStaticValidatorConfig() *StaticValidatorConfig

DefaultStaticValidatorConfig returns a default configuration

type SupabaseConfig

type SupabaseConfig struct {
	Enabled            bool   `json:"enabled"`
	JWTSecret          string `json:"jwt_secret"`
	EnableRLS          bool   `json:"enable_rls"`
	StorageIntegration bool   `json:"storage_integration"`
}

type TableRulesConfig

type TableRulesConfig struct {
	ConsolidateCreateAlter bool `json:"consolidate_create_alter"`
	RemoveDropCreateCycles bool `json:"remove_drop_create_cycles"`
	PreserveDataOperations bool `json:"preserve_data_operations"`
}

type ThirdPartyConfig

type ThirdPartyConfig struct {
	Auth0Integration       Auth0Config       `json:"auth0_integration"`
	NextAuthIntegration    NextAuthConfig    `json:"nextauth_integration"`
	SupabaseIntegration    SupabaseConfig    `json:"supabase_integration"`
	ClerkIntegration       ClerkConfig       `json:"clerk_integration"`
	VectorIntegration      VectorConfig      `json:"vector_integration"`
	PlanetScaleIntegration PlanetScaleConfig `json:"planetscale_integration"`
}

type ValidationConfig

type ValidationConfig struct {
	Mode                     string `json:"mode"`                       // Validation approach: TWO_CONTAINERS, TWO_DATABASES, or SCHEMA_DIFF
	DockerImage              string `json:"docker_image"`               // PostgreSQL Docker image (default: postgres:17)
	TimeoutSeconds           int    `json:"timeout_seconds"`            // Validation timeout in seconds (default: 120)
	ContainerReadyTimeout    int    `json:"container_ready_timeout"`    // Container startup timeout in seconds (default: 150, recommended for complex migrations with many extensions)
	EnableExtensionDetection bool   `json:"enable_extension_detection"` // Auto-detect and install extensions (default: true)
	AutoInstallExtensions    bool   `json:"auto_install_extensions"`    // Automatically install detected extensions (default: true)
	EnableSQLFixes           bool   `json:"enable_sql_fixes"`           // Apply automatic SQL fixes during validation (default: false)
	EnablePreprocessing      bool   `json:"enable_preprocessing"`       // Preprocess SQL to fix common issues (e.g., deduplicate publication statements) (default: true)
	Verbose                  bool   `json:"verbose"`                    // Show detailed validation output (default: true)
}

ValidationConfig configures Docker-based validation behavior

type ValidationErrors

type ValidationErrors struct {
	Errors []string
}

ValidationErrors contains multiple validation errors

func (*ValidationErrors) Error

func (e *ValidationErrors) Error() string

type VectorConfig

type VectorConfig struct {
	Enabled          bool     `json:"enabled"`
	DefaultIndexType string   `json:"default_index_type"`
	OptimizeQueries  bool     `json:"optimize_queries"`
	SupportedOps     []string `json:"supported_ops"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL