catbase/util/migrate/inventory.go

23 lines
490 B
Go
Raw Normal View History

2021-12-22 03:36:08 +00:00
package main
import (
"github.com/jmoiron/sqlx"
bh "github.com/timshannon/bolthold"
inventory2 "github.com/velour/catbase/plugins/inventory"
"log"
)
func migrateInventory(db *sqlx.DB, store *bh.Store) error {
allItems := []inventory2.Item{}
log.Printf("Migrating %T", allItems)
if err := db.Select(&allItems, `select * from inventory`); err != nil {
return err
}
for _, i := range allItems {
if err := store.Insert(i.Name, i); err != nil {
return err
}
}
return nil
}