(cmd *Command, args []string)
| 50 | } |
| 51 | |
| 52 | func runDrop(cmd *Command, args []string) { |
| 53 | commonFlagsInit(cmd) |
| 54 | |
| 55 | if len(args) != 1 { |
| 56 | ConsoleLog.Error("drop command need CovenantSQL dsn or database_id string as param") |
| 57 | SetExitStatus(1) |
| 58 | printCommandHelp(cmd) |
| 59 | Exit() |
| 60 | } |
| 61 | |
| 62 | configInit() |
| 63 | |
| 64 | dsn := args[0] |
| 65 | |
| 66 | // drop database |
| 67 | if _, err := client.ParseDSN(dsn); err != nil { |
| 68 | // not a dsn/dbid |
| 69 | ConsoleLog.WithField("db", dsn).WithError(err).Error("not a valid dsn") |
| 70 | SetExitStatus(1) |
| 71 | return |
| 72 | } |
| 73 | |
| 74 | txHash, err := client.Drop(dsn) |
| 75 | if err != nil { |
| 76 | // drop database failed |
| 77 | ConsoleLog.WithField("db", dsn).WithError(err).Error("drop database failed") |
| 78 | SetExitStatus(1) |
| 79 | return |
| 80 | } |
| 81 | |
| 82 | if waitTxConfirmation { |
| 83 | err = wait(txHash) |
| 84 | if err != nil { |
| 85 | ConsoleLog.WithField("db", dsn).WithError(err).Error("drop database failed") |
| 86 | SetExitStatus(1) |
| 87 | return |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | // drop database success |
| 92 | ConsoleLog.Infof("drop database %#v success", dsn) |
| 93 | return |
| 94 | } |
nothing calls this directly
no test coverage detected