cmd/mi-init: be more graceful

This commit is contained in:
Cadey Ratio 2020-01-12 02:51:33 +00:00
parent 23b8f53acf
commit 7a928aaa4a
1 changed files with 10 additions and 10 deletions

View File

@ -25,12 +25,10 @@ func main() {
} }
err = r.DB("mi").Info().Exec(session) err = r.DB("mi").Info().Exec(session)
if err == nil { if err != nil {
return if err := r.DBCreate("mi").Exec(session); err != nil {
} log.Fatal(err)
}
if err := r.DBCreate("mi").Exec(session); err != nil {
log.Fatal(err)
} }
tables := []string{ tables := []string{
@ -45,10 +43,12 @@ func main() {
var result error var result error
for _, tbl := range tables { for _, tbl := range tables {
if err := r.DB("mi").TableCreate(tbl).Exec(session); err != nil { if err := r.DB("mi").Table(tbl).Info().Exec(session); err != nil {
result = multierror.Append(result, err) if err := r.DB("mi").TableCreate(tbl).Exec(session); err != nil {
} else { result = multierror.Append(result, err)
log.Printf("created table %s", tbl) } else {
log.Printf("created table %s", tbl)
}
} }
} }