Documentation
¶
Index ¶
- func CheckToolsAvailable() error
- func CreateDump(config *DatabaseConfig, options *DumpOptions) ([]byte, error)
- func FormatConnectionInfo(config *DatabaseConfig) string
- func GetPgDumpPath() string
- func GetPgRestorePath() string
- func GetPostgresURLFromEnv() string
- func GetPostgresVersion(config *DatabaseConfig) (string, error)
- func GetPsqlPath() string
- func IsPostgresURLSet() bool
- func PurgeDatabase(config *DatabaseConfig, dryRun bool) error
- func RestoreDump(config *DatabaseConfig, dumpData []byte, options *RestoreOptions) error
- func TestConnection(config *DatabaseConfig) error
- 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
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 IsPostgresURLSet ¶
func IsPostgresURLSet() bool
IsPostgresURLSet checks if the POSTGRES_URL environment variable is set
func PurgeDatabase ¶
func PurgeDatabase(config *DatabaseConfig, dryRun bool) error
PurgeDatabase drops all tables and schemas in the database
func RestoreDump ¶
func RestoreDump(config *DatabaseConfig, dumpData []byte, options *RestoreOptions) error
RestoreDump restores a database dump using pg_restore or psql
func TestConnection ¶
func TestConnection(config *DatabaseConfig) error
TestConnection validates that the database is accessible
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