Documentation
¶
Index ¶
- Constants
- func ApplyPlanDBEnvVars(cmd *cobra.Command, hostPtr, dbPtr, userPtr, passwordPtr *string, portPtr *int)
- func Connect(config *ConnectionConfig) (*sql.DB, error)
- func ExecContextWithLogging(ctx context.Context, db *sql.DB, sqlStmt string, description string) (sql.Result, error)
- func GetEnvIntWithDefault(envVar string, defaultValue int) int
- func GetEnvWithDefault(envVar, defaultValue string) string
- func GetIRFromDatabase(host string, port int, db, user, password, schemaName, applicationName string, ...) (*ir.IR, error)
- func LoadIgnoreFile() (*ir.IgnoreConfig, error)
- func LoadIgnoreFileFromPath(filePath string) (*ir.IgnoreConfig, error)
- func LoadIgnoreFileWithStructure() (*ir.IgnoreConfig, error)
- func LoadIgnoreFileWithStructureFromPath(filePath string) (*ir.IgnoreConfig, error)
- func PreRunEWithEnvVars(dbPtr, userPtr *string) func(*cobra.Command, []string) error
- func PreRunEWithEnvVarsAndConnection(dbPtr, userPtr *string, hostPtr *string, portPtr *int) func(*cobra.Command, []string) error
- func PreRunEWithEnvVarsAndConnectionAndApp(dbPtr, userPtr *string, hostPtr *string, portPtr *int, appNamePtr *string) func(*cobra.Command, []string) error
- func ValidatePlanDBFlags(planHost, planDB, planUser string) error
- type ConnectionConfig
- type FunctionIgnoreConfig
- type ProcedureIgnoreConfig
- type SequenceIgnoreConfig
- type TableIgnoreConfig
- type TomlConfig
- type TypeIgnoreConfig
- type ViewIgnoreConfig
Constants ¶
const (
// IgnoreFileName is the default name of the ignore file
IgnoreFileName = ".pgschemaignore"
)
Variables ¶
This section is empty.
Functions ¶
func ApplyPlanDBEnvVars ¶
func ApplyPlanDBEnvVars(cmd *cobra.Command, hostPtr, dbPtr, userPtr, passwordPtr *string, portPtr *int)
ApplyPlanDBEnvVars applies environment variables to plan database connection parameters This is used in the plan command to populate plan-* flags from PGSCHEMA_PLAN_* environment variables
func Connect ¶
func Connect(config *ConnectionConfig) (*sql.DB, error)
Connect establishes a database connection using the provided configuration
func ExecContextWithLogging ¶
func ExecContextWithLogging(ctx context.Context, db *sql.DB, sqlStmt string, description string) (sql.Result, error)
ExecContextWithLogging executes SQL with debug logging if debug mode is enabled. It logs the SQL statement before execution and the result/error after execution.
func GetEnvIntWithDefault ¶
GetEnvIntWithDefault returns the value of an environment variable as int or a default value if not set
func GetEnvWithDefault ¶
GetEnvWithDefault returns the value of an environment variable or a default value if not set
func GetIRFromDatabase ¶
func GetIRFromDatabase(host string, port int, db, user, password, schemaName, applicationName string, ignoreConfig *ir.IgnoreConfig) (*ir.IR, error)
GetIRFromDatabase gets the IR from a database with ignore configuration
func LoadIgnoreFile ¶
func LoadIgnoreFile() (*ir.IgnoreConfig, error)
LoadIgnoreFile loads the .pgschemaignore file from the current directory Returns nil if the file doesn't exist (ignore functionality is optional)
func LoadIgnoreFileFromPath ¶
func LoadIgnoreFileFromPath(filePath string) (*ir.IgnoreConfig, error)
LoadIgnoreFileFromPath loads an ignore file from the specified path Returns nil if the file doesn't exist (ignore functionality is optional) Uses the structured TOML format internally
func LoadIgnoreFileWithStructure ¶
func LoadIgnoreFileWithStructure() (*ir.IgnoreConfig, error)
LoadIgnoreFileWithStructure loads the .pgschemaignore file using the structured TOML format and converts it to the simple IgnoreConfig structure
func LoadIgnoreFileWithStructureFromPath ¶
func LoadIgnoreFileWithStructureFromPath(filePath string) (*ir.IgnoreConfig, error)
LoadIgnoreFileWithStructureFromPath loads an ignore file using structured format from the specified path
func PreRunEWithEnvVars ¶
PreRunEWithEnvVars creates a PreRunE function that validates required database connection parameters It checks environment variables if the corresponding flags weren't explicitly set
func PreRunEWithEnvVarsAndConnection ¶
func PreRunEWithEnvVarsAndConnection(dbPtr, userPtr *string, hostPtr *string, portPtr *int) func(*cobra.Command, []string) error
PreRunEWithEnvVarsAndConnection creates a PreRunE function that validates database connection parameters It checks environment variables if the corresponding flags weren't explicitly set This version also handles optional host, port, and application name parameters
func PreRunEWithEnvVarsAndConnectionAndApp ¶
func PreRunEWithEnvVarsAndConnectionAndApp(dbPtr, userPtr *string, hostPtr *string, portPtr *int, appNamePtr *string) func(*cobra.Command, []string) error
PreRunEWithEnvVarsAndConnectionAndApp creates a PreRunE function that validates database connection parameters It checks environment variables if the corresponding flags weren't explicitly set This version handles all optional connection parameters including application name
func ValidatePlanDBFlags ¶
ValidatePlanDBFlags validates plan database flags when plan-host is provided Ensures required flags are present for external database usage
Types ¶
type ConnectionConfig ¶
type ConnectionConfig struct {
Host string
Port int
Database string
User string
Password string
SSLMode string
ApplicationName string
}
ConnectionConfig holds database connection parameters
type FunctionIgnoreConfig ¶
type FunctionIgnoreConfig struct {
Patterns []string `toml:"patterns,omitempty"`
}
FunctionIgnoreConfig represents function-specific ignore configuration
type ProcedureIgnoreConfig ¶
type ProcedureIgnoreConfig struct {
Patterns []string `toml:"patterns,omitempty"`
}
ProcedureIgnoreConfig represents procedure-specific ignore configuration
type SequenceIgnoreConfig ¶
type SequenceIgnoreConfig struct {
Patterns []string `toml:"patterns,omitempty"`
}
SequenceIgnoreConfig represents sequence-specific ignore configuration
type TableIgnoreConfig ¶
type TableIgnoreConfig struct {
Patterns []string `toml:"patterns,omitempty"`
}
TableIgnoreConfig represents table-specific ignore configuration
type TomlConfig ¶
type TomlConfig struct {
Tables TableIgnoreConfig `toml:"tables,omitempty"`
Views ViewIgnoreConfig `toml:"views,omitempty"`
Functions FunctionIgnoreConfig `toml:"functions,omitempty"`
Procedures ProcedureIgnoreConfig `toml:"procedures,omitempty"`
Types TypeIgnoreConfig `toml:"types,omitempty"`
Sequences SequenceIgnoreConfig `toml:"sequences,omitempty"`
}
TomlConfig represents the TOML structure of the .pgschemaignore file This is used for parsing more complex configurations if needed in the future
type TypeIgnoreConfig ¶
type TypeIgnoreConfig struct {
Patterns []string `toml:"patterns,omitempty"`
}
TypeIgnoreConfig represents type-specific ignore configuration
type ViewIgnoreConfig ¶
type ViewIgnoreConfig struct {
Patterns []string `toml:"patterns,omitempty"`
}
ViewIgnoreConfig represents view-specific ignore configuration