catbase/util/migrate/wires.go

23 lines
460 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"
"github.com/velour/catbase/plugins/rest"
"log"
)
func migrateWires(db *sqlx.DB, store *bh.Store) error {
2021-12-22 07:53:02 +00:00
wires := []rest.Wire{}
2021-12-22 03:36:08 +00:00
log.Printf("Migrating %T", wires)
if err := db.Select(&wires, `select * from wires`); err != nil {
return err
}
for _, w := range wires {
2021-12-22 07:53:02 +00:00
if err := store.Insert(bh.NextSequence(), &w); err != nil {
2021-12-22 03:36:08 +00:00
return err
}
}
return nil
}