Skip to content

Commit

Permalink
Add -verbose flag
Browse files Browse the repository at this point in the history
  • Loading branch information
kaorimatz committed Jun 21, 2018
1 parent ac6ce4e commit 4df9186
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Load a MySQL dump file using LOAD DATA INFILE.
Use LOW_PRIORITY when loading data.
-replace-table
Load data into a temporary table and replace the old table with it once load is complete.
-verbose
Verbose mode.

## Development

Expand Down
9 changes: 9 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var (
dumpFile = flag.String("dump-file", "", "MySQL dump file to load.")
lowPriority = flag.Bool("low-priority", false, "Use LOW_PRIORITY when loading data.")
replaceTable = flag.Bool("replace-table", false, "Load data into a temporary table and replace the old table with it once load is complete.")
verbose = flag.Bool("verbose", false, "Verbose mode.")
)

func init() {
Expand Down Expand Up @@ -119,6 +120,10 @@ func (e *executor) execute() (err error) {
return
}

if *verbose {
log.Printf("Creating new table %s...", quoteName(table.name))
}

if err = e.client.createTable(context.Background(), database, table.name, table.body); err != nil {
return
}
Expand Down Expand Up @@ -699,6 +704,10 @@ func (r *replacer) replace(ctx context.Context, database string, table *table) (
r.mutex.Lock()
defer r.mutex.Unlock()

if *verbose {
log.Printf("Replacing table %s with new table %s...", quoteName(table.origName), quoteName(table.name))
}

if err = r.client.dropTableIfExists(ctx, database, table.origName); err != nil {
return
}
Expand Down

0 comments on commit 4df9186

Please sign in to comment.