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