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 ¶ added in v1.4.0
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 ¶ added in v1.4.2
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 ¶ added in v1.1.1
GetEnvIntWithDefault returns the value of an environment variable as int or a default value if not set
func GetEnvWithDefault ¶ added in v1.1.1
GetEnvWithDefault returns the value of an environment variable or a default value if not set
func GetIRFromDatabase ¶ added in v1.0.0
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 ¶ added in v1.2.0
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 ¶ added in v1.2.0
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 ¶ added in v1.2.0
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 ¶ added in v1.2.0
func LoadIgnoreFileWithStructureFromPath(filePath string) (*ir.IgnoreConfig, error)
LoadIgnoreFileWithStructureFromPath loads an ignore file using structured format from the specified path
func PreRunEWithEnvVars ¶ added in v1.1.1
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 ¶ added in v1.2.0
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 ¶ added in v1.2.0
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 ¶ added in v1.4.0
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 ¶ added in v1.2.0
type FunctionIgnoreConfig struct {
Patterns []string `toml:"patterns,omitempty"`
}
FunctionIgnoreConfig represents function-specific ignore configuration
type ProcedureIgnoreConfig ¶ added in v1.2.0
type ProcedureIgnoreConfig struct {
Patterns []string `toml:"patterns,omitempty"`
}
ProcedureIgnoreConfig represents procedure-specific ignore configuration
type SequenceIgnoreConfig ¶ added in v1.2.0
type SequenceIgnoreConfig struct {
Patterns []string `toml:"patterns,omitempty"`
}
SequenceIgnoreConfig represents sequence-specific ignore configuration
type TableIgnoreConfig ¶ added in v1.2.0
type TableIgnoreConfig struct {
Patterns []string `toml:"patterns,omitempty"`
}
TableIgnoreConfig represents table-specific ignore configuration
type TomlConfig ¶ added in v1.2.0
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 ¶ added in v1.2.0
type TypeIgnoreConfig struct {
Patterns []string `toml:"patterns,omitempty"`
}
TypeIgnoreConfig represents type-specific ignore configuration
type ViewIgnoreConfig ¶ added in v1.2.0
type ViewIgnoreConfig struct {
Patterns []string `toml:"patterns,omitempty"`
}
ViewIgnoreConfig represents view-specific ignore configuration