Documentation
¶
Index ¶
Constants ¶
const ( IgnoreMapPlacement = "ignore" NoDataMapPlacement = "nodata" )
Variables ¶
This section is empty.
Functions ¶
func OpenOutput ¶
func OpenOutput(path string, compression Compression) (io.WriteCloser, string, error)
OpenOutput opens the dump destination. A path of "-" writes to stdout, which is never closed. With compression enabled the returned path carries the compression suffix. The returned writer must be closed to flush the compressor and the file.
Types ¶
type CheckConstraintSchema ¶
type ColumnSchema ¶
type ColumnSchema struct {
Name string
Type string
CharacterSet sql.NullString
Nullable bool
Default sql.NullString
Extra string
Collation sql.NullString
Comment string
GenerationExpr sql.NullString
IsVirtual bool
CheckExpr string
}
func (*ColumnSchema) IsBinary ¶
func (c *ColumnSchema) IsBinary() bool
func (*ColumnSchema) IsGenerated ¶
func (c *ColumnSchema) IsGenerated() bool
type Compression ¶
type Compression string
Compression selects how the dump output is compressed.
const ( CompressionNone Compression = "" CompressionGzip Compression = "gzip" CompressionZstd Compression = "zstd" )
func ParseCompression ¶
func ParseCompression(s string) (Compression, error)
ParseCompression validates a user-provided compression name.
type Dumper ¶
type Dumper struct {
// SelectMap contains column rewrites per table (table -> column -> SQL expression)
SelectMap map[string]map[string]string
// WhereMap contains WHERE clauses per table (table -> WHERE clause)
WhereMap map[string]string
// NoData contains list of tables to dump structure only (no data), supports glob wildcards (e.g. "cart*")
NoData []string
// Ignore contains list of tables to skip entirely, supports glob wildcards (e.g. "cart*")
Ignore []string
// LimitMap contains row limits per table (table -> limit). Tables referencing
// a limited table via foreign keys are filtered automatically.
LimitMap map[string]TableLimit
// LockTables controls whether to lock tables during dump (default: true)
LockTables bool
// Quick enables quick mode for mysqldump (default: false)
Quick bool
// InsertIntoLimit controls how many rows are included in each INSERT statement (default: 100).
// When set to a positive value, it takes priority over Quick mode.
// When not set (0 or negative) and Quick is true, the batch size is 1.
InsertIntoLimit int
// Parallel controls how many tables to dump concurrently (default: 0 = disabled)
Parallel int
// contains filtered or unexported fields
}
func NewMySQLDumper ¶
NewMySQLDumper creates a new MySQL dumper with default configuration.
type ForeignKeySchema ¶
type IndexColumnSchema ¶
type IndexSchema ¶
type TableLimit ¶
type TableLimit struct {
// Maximum amount of rows to export for this table
Rows int `yaml:"rows" jsonschema:"required,minimum=1"`
// SQL ORDER BY clause deciding which rows are kept (e.g. "created_at DESC" for the newest rows). Defaults to "created_at DESC" when the table has a created_at column
OrderBy string `yaml:"order_by,omitempty"`
}
TableLimit restricts how many rows of a table are dumped. All tables referencing the limited table via foreign keys (directly or transitively) are filtered automatically so they only contain rows attached to the kept rows. A second limit on a table that is already filtered this way is rejected. When the limited table references itself (e.g. product.parent_id), the ancestors of the kept rows are dumped too, so the export may hold slightly more than Rows rows but stays importable with foreign key checks enabled.
type TableSchema ¶
type TableSchema struct {
Name string
Engine string
Charset string
Collation string
Comment string
RowFormat string
AutoIncrement sql.NullInt64
Columns []ColumnSchema
PrimaryKey []string
Indexes []IndexSchema
ForeignKeys []ForeignKeySchema
CheckConstraints []CheckConstraintSchema
}
func (*TableSchema) BuildCreateTableSQL ¶
func (schema *TableSchema) BuildCreateTableSQL() string
func (*TableSchema) GetBinaryColumns ¶
func (schema *TableSchema) GetBinaryColumns() []string
func (*TableSchema) GetGeneratedColumns ¶
func (schema *TableSchema) GetGeneratedColumns() []string