snapshot

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CharsetWhite added in v1.5.0

func CharsetWhite() []string

func IsCannotAddOrUpdateAChildRowError added in v1.5.0

func IsCannotAddOrUpdateAChildRowError(err error) bool

func MaxSampling added in v1.5.0

func MaxSampling() uint64

MaxSampling returns the max sampling size. Set it by env "PIPELINE_MIGRATION_SAMPLING_SIZE"

func ParseCreateTableStmt added in v1.3.0

func ParseCreateTableStmt(create string) (*ast.CreateTableStmt, error)

ParseCreateTableStmt parses CreateTableStmt as *ast.CreateTableStmt node

func Sampling added in v1.5.0

func Sampling() bool

Sampling returns true if it needs to sampling when snapshot. Set it by env "PIPELINE_MIGRATION_DATABASE=true"

func TrimBlockFormat added in v1.5.0

func TrimBlockFormat(create string) string

func TrimCharacterSetFromRawCreateTableSQL

func TrimCharacterSetFromRawCreateTableSQL(create string, except ...string) string

func TrimCollateOptionFromCols

func TrimCollateOptionFromCols(create *ast.CreateTableStmt)

func TrimCollateOptionFromCreateTable

func TrimCollateOptionFromCreateTable(create *ast.CreateTableStmt)

func TrimConstraintCheckFromCreateTable

func TrimConstraintCheckFromCreateTable(create *ast.CreateTableStmt)

Types

type Snapshot

type Snapshot struct {
	// contains filtered or unexported fields
}

Snapshot maintains the structure of the database tables

func From

func From(tx *gorm.DB, ignore ...string) (s *Snapshot, err error)

From snapshots the structure of the database tables, and returns the Snapshot. tx is the connection handler of the goal DB. ignore is the tables you do not want to snapshot.

func (*Snapshot) DDLNodes

func (s *Snapshot) DDLNodes() []ast.DDLNode

DDLNodes returns DDLs

func (*Snapshot) Dump added in v1.5.0

func (s *Snapshot) Dump(tableName string, lines uint64) ([]map[string]interface{}, uint64, error)

Dump dumps data from DB. tableName is the table you want to dump. lines is the numbers of lines you want to dump. Note: lines is an approximate number rather than an exact number. Note: the max data size is not more than 1<<16 (the MySQL default max placeholders size).

func (*Snapshot) HasAnyTable

func (s *Snapshot) HasAnyTable() bool

HasAnyTable returns true if there is any table in the Snapshot

func (*Snapshot) RecoverTo

func (s *Snapshot) RecoverTo(tx *gorm.DB) error

RecoverTo recover the data structure and data to goal db

func (*Snapshot) TableNames

func (s *Snapshot) TableNames() []string

TableNames returns all tables names

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL