instead of loading the entire context, only updating particular fields from the resurrected context
This commit is contained in:
parent
5f25f741ad
commit
89ca346919
@ -255,10 +255,6 @@ func (this *MigrationContext) LoadJSON(jsonString string) error {
|
||||
this.throttleMutex.Lock()
|
||||
defer this.throttleMutex.Unlock()
|
||||
|
||||
// Some stuff that is in context but is more of a config that may be overriden by --resurrect kind of execution:
|
||||
// Push
|
||||
hooksPath := this.HooksPath
|
||||
|
||||
jsonBytes := []byte(jsonString)
|
||||
err := json.Unmarshal(jsonBytes, this)
|
||||
|
||||
@ -275,12 +271,25 @@ func (this *MigrationContext) LoadJSON(jsonString string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Pop
|
||||
this.HooksPath = hooksPath
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// GetGhostTableName generates the name of ghost table, based on original table name
|
||||
func (this *MigrationContext) ApplyResurrectedContext(other *MigrationContext) {
|
||||
this.MigrationRangeMinValues = other.MigrationRangeMinValues
|
||||
this.MigrationRangeMaxValues = other.MigrationRangeMaxValues
|
||||
this.MigrationIterationRangeMinValues = other.MigrationIterationRangeMinValues
|
||||
this.MigrationIterationRangeMaxValues = other.MigrationIterationRangeMaxValues
|
||||
|
||||
this.RowsEstimate = other.RowsEstimate
|
||||
this.RowsDeltaEstimate = other.RowsDeltaEstimate
|
||||
this.TotalRowsCopied = other.TotalRowsCopied
|
||||
this.TotalDMLEventsApplied = other.TotalDMLEventsApplied
|
||||
|
||||
this.Iteration = other.Iteration
|
||||
this.StreamerBinlogCoordinates = other.StreamerBinlogCoordinates
|
||||
}
|
||||
|
||||
// GetGhostTableName generates the name of ghost table, based on original table name
|
||||
func (this *MigrationContext) GetGhostTableName() string {
|
||||
return fmt.Sprintf("_%s_gho", this.OriginalTableName)
|
||||
|
@ -282,7 +282,7 @@ func (this *Migrator) resurrect() error {
|
||||
}
|
||||
log.Infof("Proceeding to resurrection")
|
||||
|
||||
// Dry run: loading migration context to a temporary location just to confirm there's no errors:
|
||||
// Loading migration context to a temporary location:
|
||||
loadedContext := base.NewMigrationContext()
|
||||
if err := loadedContext.LoadJSON(encodedContext); err != nil {
|
||||
return err
|
||||
@ -297,10 +297,9 @@ func (this *Migrator) resurrect() error {
|
||||
if this.migrationContext.AlterStatement != loadedContext.AlterStatement {
|
||||
return fmt.Errorf("Resurrection: given --alter statement not identical to resurrected one. Bailing out")
|
||||
}
|
||||
// Happy. Let's go live and load the context for real.
|
||||
if err := this.migrationContext.LoadJSON(encodedContext); err != nil {
|
||||
return err
|
||||
}
|
||||
// Happy. Let's go live and update our real context
|
||||
this.migrationContext.ApplyResurrectedContext(loadedContext)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/gob"
|
||||
// "encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
@ -277,11 +276,6 @@ func (this *ColumnValues) ToBase64() (b64 string, err error) {
|
||||
return base64.StdEncoding.EncodeToString(buff.Bytes()), nil
|
||||
}
|
||||
|
||||
// // MarshalJSON will marshal this object as JSON
|
||||
// func (this *ColumnValues) MarshalJSON() ([]byte, error) {
|
||||
// return json.Marshal(this.abstractValues)
|
||||
// }
|
||||
|
||||
func (this *ColumnValues) AbstractValues() []interface{} {
|
||||
return this.abstractValues
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user