sanity checks for resurrection
This commit is contained in:
parent
c72851e1f6
commit
171cad2a98
@ -180,11 +180,13 @@ func main() {
|
||||
if *cliMasterPassword != "" && migrationContext.AssumeMasterHostname == "" {
|
||||
log.Fatalf("--master-password requires --assume-master-host")
|
||||
}
|
||||
if migrationContext.InitiallyDropGhostTable && migrationContext.Resurrect {
|
||||
log.Fatalf("--initially-drop-ghost-table and --resurrect are mutually exclusive")
|
||||
if migrationContext.Resurrect && migrationContext.InitiallyDropGhostTable {
|
||||
migrationContext.InitiallyDropGhostTable = false
|
||||
log.Warningf("--resurrect given, implicitly disabling --initially-drop-ghost-table")
|
||||
}
|
||||
if migrationContext.InitiallyDropOldTable && migrationContext.Resurrect {
|
||||
log.Fatalf("--initially-drop-old-table and --resurrect are mutually exclusive")
|
||||
if migrationContext.Resurrect && migrationContext.InitiallyDropOldTable {
|
||||
migrationContext.InitiallyDropOldTable = false
|
||||
log.Warningf("--resurrect given, implicitly disabling --initially-drop-old-table")
|
||||
}
|
||||
|
||||
switch *cutOver {
|
||||
|
@ -128,6 +128,19 @@ func (this *Applier) tableExists(tableName string) (tableFound bool) {
|
||||
// ValidateOrDropExistingTables verifies ghost and changelog tables do not exist,
|
||||
// or attempts to drop them if instructed to.
|
||||
func (this *Applier) ValidateOrDropExistingTables() error {
|
||||
if this.migrationContext.Resurrect {
|
||||
ghostTableExists := this.tableExists(this.migrationContext.GetGhostTableName())
|
||||
if !ghostTableExists {
|
||||
return fmt.Errorf("--ressurect requested, but ghost table %s doesn't exist. Panicking.", this.migrationContext.GetGhostTableName())
|
||||
}
|
||||
changelogTableExists := this.tableExists(this.migrationContext.GetChangelogTableName())
|
||||
if !changelogTableExists {
|
||||
return fmt.Errorf("--ressurect requested, but changelog table %s doesn't exist. Panicking.", this.migrationContext.GetChangelogTableName())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// Normal mode (no resurrection)
|
||||
|
||||
if this.migrationContext.InitiallyDropGhostTable {
|
||||
if err := this.DropGhostTable(); err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user