catbase/util/migrate/last.go

23 lines
473 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"
last2 "github.com/velour/catbase/plugins/last"
"log"
)
func migrateLast(db *sqlx.DB, store *bh.Store) error {
allLast := []last2.Last{}
log.Printf("Migrating %T", allLast)
if err := db.Select(&allLast, `select * from last`); err != nil {
return err
}
for _, i := range allLast {
if err := store.Insert(bh.NextSequence(), &i); err != nil {
return err
}
}
return nil
}