package main import ( "github.com/jmoiron/sqlx" bh "github.com/timshannon/bolthold" webshit2 "github.com/velour/catbase/plugins/newsbid/webshit" "log" "time" ) type BidSQL struct { webshit2.Bid Placed int64 Processed int64 } func migrateWebshit(db *sqlx.DB, store *bh.Store) error { balances := []webshit2.Balance{} bids := []BidSQL{} log.Printf("Migrating %T", balances) if err := db.Select(&balances, `select * from webshit_balances`); err != nil { return err } for _, b := range balances { if err := store.Insert(bh.NextSequence(), &b); err != nil { return err } } log.Printf("Migrating %T", bids) if err := db.Select(&bids, `select * from webshit_bids`); err != nil { return err } for _, b := range bids { bid := b.Bid bid.Placed = time.Unix(b.Placed, 0) bid.Processed = time.Unix(b.Processed, 0) if err := store.Insert(bh.NextSequence(), &bid); err != nil { return err } } return nil }