mirror of https://github.com/velour/catbase.git
23 lines
490 B
Go
23 lines
490 B
Go
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
|
|
}
|