Merge pull request #81 from github/noop-show-create-table
a noop operation dumps SHOW CREATE TABLE
This commit is contained in:
commit
b4a2a3bfbe
@ -516,6 +516,14 @@ func (this *Inspector) getSharedColumns(originalColumns, ghostColumns *sql.Colum
|
||||
return sql.NewColumnList(sharedColumnNames), sql.NewColumnList(mappedSharedColumnNames)
|
||||
}
|
||||
|
||||
// showCreateTable returns the `show create table` statement for given table
|
||||
func (this *Inspector) showCreateTable(tableName string) (createTableStatement string, err error) {
|
||||
var dummy string
|
||||
query := fmt.Sprintf(`show /* gh-ost */ create table %s.%s`, sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(tableName))
|
||||
err = this.db.QueryRow(query).Scan(&dummy, &createTableStatement)
|
||||
return createTableStatement, err
|
||||
}
|
||||
|
||||
// readChangelogState reads changelog hints
|
||||
func (this *Inspector) readChangelogState() (map[string]string, error) {
|
||||
query := fmt.Sprintf(`
|
||||
|
@ -1173,6 +1173,16 @@ func (this *Migrator) executeWriteFuncs() error {
|
||||
// finalCleanup takes actions at very end of migration, dropping tables etc.
|
||||
func (this *Migrator) finalCleanup() error {
|
||||
atomic.StoreInt64(&this.cleanupImminentFlag, 1)
|
||||
|
||||
if this.migrationContext.Noop {
|
||||
if createTableStatement, err := this.inspector.showCreateTable(this.migrationContext.GetGhostTableName()); err == nil {
|
||||
log.Infof("New table structure follows")
|
||||
fmt.Println(createTableStatement)
|
||||
} else {
|
||||
log.Errore(err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := this.retryOperation(this.applier.DropChangelogTable); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user