2016-04-01 11:36:56 +00:00
|
|
|
/*
|
|
|
|
Copyright 2016 GitHub Inc.
|
|
|
|
See https://github.com/github/gh-osc/blob/master/LICENSE
|
|
|
|
*/
|
|
|
|
|
|
|
|
package base
|
|
|
|
|
|
|
|
import ()
|
|
|
|
|
2016-04-04 10:27:51 +00:00
|
|
|
type RowsEstimateMethod string
|
|
|
|
|
|
|
|
const (
|
|
|
|
TableStatusRowsEstimate RowsEstimateMethod = "TableStatusRowsEstimate"
|
|
|
|
ExplainRowsEstimate = "ExplainRowsEstimate"
|
|
|
|
CountRowsEstimate = "CountRowsEstimate"
|
|
|
|
)
|
|
|
|
|
2016-04-01 11:36:56 +00:00
|
|
|
type MigrationContext struct {
|
2016-04-04 10:27:51 +00:00
|
|
|
DatabaseName string
|
|
|
|
OriginalTableName string
|
|
|
|
GhostTableName string
|
|
|
|
AlterStatement string
|
|
|
|
TableEngine string
|
|
|
|
CountTableRows bool
|
|
|
|
RowsEstimate int64
|
|
|
|
UsedRowsEstimateMethod RowsEstimateMethod
|
|
|
|
ChunkSize int
|
|
|
|
OriginalBinlogFormat string
|
|
|
|
OriginalBinlogRowImage string
|
2016-04-01 11:36:56 +00:00
|
|
|
}
|
2016-04-01 14:05:44 +00:00
|
|
|
|
2016-04-04 10:27:51 +00:00
|
|
|
var context *MigrationContext
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
context = newMigrationContext()
|
|
|
|
}
|
2016-04-01 14:05:44 +00:00
|
|
|
|
|
|
|
func newMigrationContext() *MigrationContext {
|
2016-04-04 10:27:51 +00:00
|
|
|
return &MigrationContext{
|
|
|
|
ChunkSize: 1000,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetMigrationContext() *MigrationContext {
|
|
|
|
return context
|
|
|
|
}
|
|
|
|
|
|
|
|
// RequiresBinlogFormatChange
|
|
|
|
func (this *MigrationContext) RequiresBinlogFormatChange() bool {
|
|
|
|
return this.OriginalBinlogFormat != "ROW"
|
2016-04-01 14:05:44 +00:00
|
|
|
}
|