Documentation
¶
Index ¶
- func CountCSVDataRows(path string, hasHeader bool) int
- func DumpDatabase(dbURL, dumpPath string) error
- func DumpDatabaseWithConnection(profile config.Profile, dumpPath string) error
- func DumpDatabaseWithConnectionAndOptions(profile config.Profile, dumpPath string, options *DumpOptions) error
- func DumpDatabaseWithOptions(dbURL, dumpPath string, options *DumpOptions) error
- func ExportCSV(db *sql.DB, table, exportPath string) error
- func ExportCSVWithOptions(db *sql.DB, table, exportPath string, options *CSVOptions) error
- func ExportCSVWithQuery(db *sql.DB, query, exportPath string, includeHeaders bool) (int, error)
- func FormatCSVValue(v interface{}) string
- func ImportCSV(db *sql.DB, table, importPath string) error
- func ImportCSVWithOptions(db *sql.DB, table, importPath string, options *CSVOptions) error
- func MigrateDatabaseWithConnection(opts *MigrationOptions) error
- func MigrateDatabaseWithOptions(opts *MigrationOptions) error
- func NewProgressBarWithTimer(total int64, description string) *progressbar.ProgressBar
- func RestoreDatabase(dbURL, dumpPath string) error
- func RestoreDatabaseSmart(dbURL, dumpPath string) error
- func RestoreDatabaseSmartWithOptions(dbURL, dumpPath string, options *RestoreOptions) error
- func RestoreDatabaseWithConnection(profile config.Profile, dumpPath string) error
- func RestoreDatabaseWithConnectionAndOptions(profile config.Profile, dumpPath string, options *RestoreOptions) error
- type CSVOptions
- type DumpOptions
- type MigrationOptions
- type RestoreOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountCSVDataRows ¶
CountCSVDataRows best-effort counts data rows in a CSV file, optionally excluding the header row.
func DumpDatabase ¶
func DumpDatabaseWithConnection ¶
DumpDatabaseWithConnection performs a database dump using a DBConnection (supports SSH tunnels)
func DumpDatabaseWithConnectionAndOptions ¶
func DumpDatabaseWithConnectionAndOptions(profile config.Profile, dumpPath string, options *DumpOptions) error
DumpDatabaseWithConnectionAndOptions performs a database dump with advanced options using DBConnection
func DumpDatabaseWithOptions ¶
func DumpDatabaseWithOptions(dbURL, dumpPath string, options *DumpOptions) error
DumpDatabaseWithOptions performs a database dump with advanced options
func ExportCSVWithOptions ¶
func ExportCSVWithOptions(db *sql.DB, table, exportPath string, options *CSVOptions) error
ExportCSVWithOptions exports a PostgreSQL table to CSV with batch processing for better memory efficiency
func ExportCSVWithQuery ¶
ExportCSVWithQuery runs an arbitrary SELECT and writes the results to a CSV file. It returns the number of data rows written (headers excluded).
func FormatCSVValue ¶
func FormatCSVValue(v interface{}) string
formatCSVValue properly formats a value for CSV export
func ImportCSVWithOptions ¶
func ImportCSVWithOptions(db *sql.DB, table, importPath string, options *CSVOptions) error
ImportCSVWithOptions imports data from a CSV file with batch processing for better performance
func MigrateDatabaseWithConnection ¶
func MigrateDatabaseWithConnection(opts *MigrationOptions) error
MigrateDatabaseWithConnection performs database migration using DBConnection objects for SSH support
func MigrateDatabaseWithOptions ¶
func MigrateDatabaseWithOptions(opts *MigrationOptions) error
MigrateDatabaseWithOptions performs database migration with specified options
func NewProgressBarWithTimer ¶
func NewProgressBarWithTimer(total int64, description string) *progressbar.ProgressBar
NewProgressBarWithTimer creates a progress bar (or a spinner when the total is unknown/non-positive) and starts a goroutine that continuously appends an elapsed-time suffix to the bar's description.
func RestoreDatabase ¶
func RestoreDatabaseSmart ¶
RestoreDatabaseSmart automatically detects dump format and uses appropriate tool
func RestoreDatabaseSmartWithOptions ¶
func RestoreDatabaseSmartWithOptions(dbURL, dumpPath string, options *RestoreOptions) error
RestoreDatabaseSmartWithOptions detects the dump format and restores it, honouring the supplied RestoreOptions.
func RestoreDatabaseWithConnection ¶
RestoreDatabaseWithConnection performs a database restore using a DBConnection (supports SSH tunnels) RestoreDatabaseWithConnection performs a database restore using a DBConnection (supports SSH tunnels)
func RestoreDatabaseWithConnectionAndOptions ¶
func RestoreDatabaseWithConnectionAndOptions(profile config.Profile, dumpPath string, options *RestoreOptions) error
RestoreDatabaseWithConnectionAndOptions performs a database restore using a DBConnection (supports SSH tunnels), honouring the supplied RestoreOptions.
Types ¶
type CSVOptions ¶
type CSVOptions struct {
BatchSize int // Number of rows to process in each batch (default: 500)
HasHeader bool // Whether the first row of the CSV contains column headers
}
CSVOptions contains configuration for CSV operations
func DefaultCSVOptions ¶
func DefaultCSVOptions() *CSVOptions
DefaultCSVOptions returns default CSV configuration
type DumpOptions ¶
type DumpOptions struct {
Format string // plain, custom, directory, tar
Compress bool // Enable compression
SchemaOnly bool // Export schema only
DataOnly bool // Export data only
Tables []string // Specific tables to include
ExcludeTables []string // Tables to exclude
Schema string // Specific schema
Verbose bool // Verbose output
Timeout int // Command timeout in seconds
}
DumpOptions contains advanced options for pg_dump
type MigrationOptions ¶
type MigrationOptions struct {
SourceProfile config.Profile
TargetProfile config.Profile
SchemaOnly bool
DataOnly bool
Tables []string
Validate bool
EnableRollback bool
Verbose bool
Timeout int
Overwrite bool
BatchSize int
}
MigrationOptions defines options for database migration
type RestoreOptions ¶
type RestoreOptions struct {
// Clean drops database objects before recreating them (pg_restore only).
Clean bool
// Timeout, when > 0, aborts the restore after the given number of seconds.
Timeout int
// Strict makes any restore error fatal. By default restore tolerates
// non-fatal errors reported by pg_restore (e.g. minor client/server
// version mismatches such as "unrecognized configuration parameter").
// Note that pg_restore exits with code 1 when it encounters ignorable
// errors, so the default (Strict == false) keeps restores resilient to
// version skew.
Strict bool
}
RestoreOptions controls restore behaviour for pg_restore/psql.