mirror of https://github.com/velour/catbase.git
33 lines
744 B
Go
33 lines
744 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"github.com/jmoiron/sqlx"
|
||
|
bh "github.com/timshannon/bolthold"
|
||
|
"github.com/velour/catbase/bot"
|
||
|
"log"
|
||
|
)
|
||
|
|
||
|
func migrateBlackWhite(db *sqlx.DB, store *bh.Store) error {
|
||
|
allBlack := []bot.BlacklistItem{}
|
||
|
allWhite := []bot.WhitelistItem{}
|
||
|
log.Printf("Migrating %T", allBlack)
|
||
|
if err := db.Select(&allBlack, `select * from pluginBlacklist`); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
for _, i := range allBlack {
|
||
|
if err := store.Insert(i.Key(), i); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
}
|
||
|
log.Printf("Migrating %T", allWhite)
|
||
|
if err := db.Select(&allWhite, `select * from pluginWhitelist`); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
for _, i := range allWhite {
|
||
|
if err := store.Insert(i.Name, i); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
}
|
||
|
return nil
|
||
|
}
|