Documentation
¶
Overview ¶
Package copier provides functionality for copying data between PostgreSQL databases
Index ¶
- Constants
- func ValidateConfig(config *Config) error
- type Config
- type Copier
- type CopyStats
- type ForeignKey
- type ForeignKeyManager
- func (fkm *ForeignKeyManager) CleanupBackupFile() error
- func (fkm *ForeignKeyManager) DetectForeignKeys(tables []*TableInfo) error
- func (fkm *ForeignKeyManager) DisableReplicaMode() error
- func (fkm *ForeignKeyManager) DropForeignKeysForTable(table *TableInfo) error
- func (fkm *ForeignKeyManager) GetForeignKeyStats() (total, dropped int)
- func (fkm *ForeignKeyManager) IsUsingReplicaMode() bool
- func (fkm *ForeignKeyManager) RecoverFromBackupFile() error
- func (fkm *ForeignKeyManager) RestoreForeignKeysForTable(table *TableInfo) error
- func (fkm *ForeignKeyManager) TryUseReplicaMode() error
- type Logger
- type TableInfo
Constants ¶
const ( ColorReset = "\033[0m" ColorRed = "\033[31m" ColorGreen = "\033[32m" ColorYellow = "\033[33m" ColorBlue = "\033[34m" ColorMagenta = "\033[35m" ColorCyan = "\033[36m" ColorWhite = "\033[37m" ColorBold = "\033[1m" ColorDim = "\033[2m" )
ANSI color codes
Variables ¶
This section is empty.
Functions ¶
func ValidateConfig ¶
ValidateConfig validates the configuration
Types ¶
type Config ¶
type Config struct {
SourceConn string
DestConn string
SourceFile string
DestFile string
Parallel int
BatchSize int
ExcludeTables []string
IncludeTables []string
Resume bool
DryRun bool
ProgressBar bool
}
Config holds the configuration for the data copy operation
type Copier ¶
type Copier struct {
// contains filtered or unexported fields
}
Copier handles the data copying operation
type CopyStats ¶
type CopyStats struct {
TablesProcessed int64
RowsCopied int64
TotalTables int64
TotalRows int64
ForeignKeysDetected int64
ForeignKeysDropped int64
StartTime time.Time
Errors []error
}
CopyStats tracks copying statistics
type ForeignKey ¶
type ForeignKey struct {
ConstraintName string
Schema string
Table string
Columns []string
ReferencedSchema string
ReferencedTable string
ReferencedColumns []string
OnDelete string
OnUpdate string
Definition string // Full CREATE CONSTRAINT statement
}
ForeignKey represents a foreign key constraint
type ForeignKeyManager ¶
type ForeignKeyManager struct {
// contains filtered or unexported fields
}
ForeignKeyManager handles foreign key operations
func NewForeignKeyManager ¶
func NewForeignKeyManager(db *sql.DB, logger Logger) *ForeignKeyManager
NewForeignKeyManager creates a new foreign key manager
func (*ForeignKeyManager) CleanupBackupFile ¶
func (fkm *ForeignKeyManager) CleanupBackupFile() error
CleanupBackupFile removes the backup file on successful completion
func (*ForeignKeyManager) DetectForeignKeys ¶
func (fkm *ForeignKeyManager) DetectForeignKeys(tables []*TableInfo) error
DetectForeignKeys discovers all foreign keys in the database
func (*ForeignKeyManager) DisableReplicaMode ¶
func (fkm *ForeignKeyManager) DisableReplicaMode() error
DisableReplicaMode disables replica mode
func (*ForeignKeyManager) DropForeignKeysForTable ¶
func (fkm *ForeignKeyManager) DropForeignKeysForTable(table *TableInfo) error
DropForeignKeysForTable drops all foreign keys that reference or are referenced by a table
func (*ForeignKeyManager) GetForeignKeyStats ¶
func (fkm *ForeignKeyManager) GetForeignKeyStats() (total, dropped int)
GetForeignKeyStats returns statistics about foreign keys
func (*ForeignKeyManager) IsUsingReplicaMode ¶
func (fkm *ForeignKeyManager) IsUsingReplicaMode() bool
IsUsingReplicaMode returns whether replica mode is enabled
func (*ForeignKeyManager) RecoverFromBackupFile ¶
func (fkm *ForeignKeyManager) RecoverFromBackupFile() error
RecoverFromBackupFile attempts to restore FKs from backup file if they exist but weren't tracked
func (*ForeignKeyManager) RestoreForeignKeysForTable ¶
func (fkm *ForeignKeyManager) RestoreForeignKeysForTable(table *TableInfo) error
RestoreForeignKeysForTable restores foreign keys related to a specific table
func (*ForeignKeyManager) TryUseReplicaMode ¶
func (fkm *ForeignKeyManager) TryUseReplicaMode() error
TryUseReplicaMode attempts to use replica mode for FK handling