mirror of https://github.com/velour/catbase.git
32 lines
664 B
Go
32 lines
664 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"github.com/jmoiron/sqlx"
|
||
|
"github.com/rs/zerolog/log"
|
||
|
bh "github.com/timshannon/bolthold"
|
||
|
)
|
||
|
|
||
|
type PassEntry struct {
|
||
|
ID int64 `json:"id"`
|
||
|
Secret string `json:"secret"`
|
||
|
|
||
|
// Should be null unless inserting a new entry
|
||
|
Pass string `json:"pass"`
|
||
|
EncodedPass []byte `db:"encoded_pass"`
|
||
|
Cost int `json:"cost"`
|
||
|
}
|
||
|
|
||
|
func migrateApppass(db *sqlx.DB, store *bh.Store) error {
|
||
|
all := []PassEntry{}
|
||
|
log.Printf("Migrating %T", all)
|
||
|
if err := db.Select(&all, `select * from apppass`); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
for _, i := range all {
|
||
|
if err := store.Insert(i.ID, i); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
}
|
||
|
return nil
|
||
|
}
|