Documentation
¶
Index ¶
- func CheckToolsAvailable() error
- func CreateDump(config *DatabaseConfig, options *DumpOptions) ([]byte, error)
- func ExtractMajorVersion(versionStr string) string
- func FormatConnectionInfo(config *DatabaseConfig) string
- func GetPgDumpPath() string
- func GetPgRestorePath() string
- func GetPostgresURLFromEnv() string
- func GetPostgresVersion(config *DatabaseConfig) (string, error)
- func GetPsqlPath() string
- func IsDockerAvailable() bool
- func IsPostgresURLSet() bool
- func NeedsDockerHostNetwork(host string) bool
- func PurgeDatabase(config *DatabaseConfig, dryRun bool) error
- func ResolveDockerHost(host string) string
- func RestoreDump(config *DatabaseConfig, dumpData []byte, options *RestoreOptions) error
- func TestConnection(config *DatabaseConfig) error
- func UseDockerPgTools() bool
- func ValidateConfig(config *DatabaseConfig) error
- type DatabaseBackupMetadata
- type DatabaseConfig
- type DumpOptions
- type RestoreOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckToolsAvailable ¶
func CheckToolsAvailable() error
CheckToolsAvailable verifies that pg_dump and pg_restore are installed
func CreateDump ¶
func CreateDump(config *DatabaseConfig, options *DumpOptions) ([]byte, error)
CreateDump creates a database dump using pg_dump (or Docker)
func ExtractMajorVersion ¶ added in v0.17.0
ExtractMajorVersion extracts the major version from a PostgreSQL version string Example: "PostgreSQL 17.4 (Debian 17.4-1.pgdg120+1)" -> "17"
func FormatConnectionInfo ¶
func FormatConnectionInfo(config *DatabaseConfig) string
FormatConnectionInfo returns a safe string representation of the connection (without password) for logging purposes
func GetPgDumpPath ¶
func GetPgDumpPath() string
GetPgDumpPath returns the path to the pg_dump binary Checks PG_DUMP_BINARY environment variable, defaults to /usr/local/bin/pg_dump
func GetPgRestorePath ¶
func GetPgRestorePath() string
GetPgRestorePath returns the path to the pg_restore binary Checks PG_RESTORE_BINARY environment variable, defaults to /usr/local/bin/pg_restore
func GetPostgresURLFromEnv ¶
func GetPostgresURLFromEnv() string
GetPostgresURLFromEnv retrieves the POSTGRES_URL environment variable
func GetPostgresVersion ¶
func GetPostgresVersion(config *DatabaseConfig) (string, error)
GetPostgresVersion retrieves the PostgreSQL server version
func GetPsqlPath ¶
func GetPsqlPath() string
GetPsqlPath returns the path to the psql binary Checks PSQL_BINARY environment variable, defaults to /usr/local/bin/psql
func IsDockerAvailable ¶ added in v0.17.0
func IsDockerAvailable() bool
IsDockerAvailable checks if Docker is installed and accessible
func IsPostgresURLSet ¶
func IsPostgresURLSet() bool
IsPostgresURLSet checks if the POSTGRES_URL environment variable is set
func NeedsDockerHostNetwork ¶ added in v0.17.0
NeedsDockerHostNetwork returns true if Docker should use --network=host This is needed on Linux when connecting to localhost
func PurgeDatabase ¶
func PurgeDatabase(config *DatabaseConfig, dryRun bool) error
PurgeDatabase drops all tables and schemas in the database
func ResolveDockerHost ¶ added in v0.17.0
ResolveDockerHost resolves localhost addresses for Docker containers On Mac/Windows: localhost -> host.docker.internal On Linux: returns original host (will use --network=host flag instead)
func RestoreDump ¶
func RestoreDump(config *DatabaseConfig, dumpData []byte, options *RestoreOptions) error
RestoreDump restores a database dump using pg_restore or psql (or Docker)
func TestConnection ¶
func TestConnection(config *DatabaseConfig) error
TestConnection validates that the database is accessible
func UseDockerPgTools ¶ added in v0.17.0
func UseDockerPgTools() bool
UseDockerPgTools checks if Docker should be used for PostgreSQL tools Checks USE_DOCKER_PG_TOOLS environment variable
func ValidateConfig ¶
func ValidateConfig(config *DatabaseConfig) error
ValidateConfig performs basic validation on a DatabaseConfig
Types ¶
type DatabaseBackupMetadata ¶
type DatabaseBackupMetadata struct {
BackupTimestamp string
DatabaseName string
PostgresVersion string
DumpFormat string
Compressed bool
}
DatabaseBackupMetadata tracks database backup information
type DatabaseConfig ¶
type DatabaseConfig struct {
URL string // Full connection string
Host string
Port int
Database string
User string
Password string
}
DatabaseConfig holds PostgreSQL connection details
func ParsePostgresURL ¶
func ParsePostgresURL(connectionURL string) (*DatabaseConfig, error)
ParsePostgresURL parses a PostgreSQL connection string into a DatabaseConfig Expected format: postgres://user:password@host:port/dbname