mirror of https://github.com/velour/catbase.git
157 lines
3.4 KiB
Go
157 lines
3.4 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"github.com/jmoiron/sqlx"
|
|
bh "github.com/timshannon/bolthold"
|
|
"go.etcd.io/bbolt"
|
|
"log"
|
|
)
|
|
|
|
var (
|
|
dbPath = flag.String("db", "catbase.db", "path to sqlite db")
|
|
storePath = flag.String("store", "catbase.store", "path to bolthold store")
|
|
|
|
fact = flag.Bool("fact", false, "migrate facts")
|
|
config = flag.Bool("config", false, "migrate config")
|
|
babbler = flag.Bool("babbler", false, "migrate babbler")
|
|
beers = flag.Bool("beers", false, "migrate beers")
|
|
awards = flag.Bool("awards", false, "migrate awards")
|
|
webshit = flag.Bool("webshit", false, "migrate webshit")
|
|
wire = flag.Bool("wire", false, "migrate wires")
|
|
tell = flag.Bool("tell", false, "migrate tell")
|
|
sms = flag.Bool("sms", false, "migrate sms")
|
|
reminders = flag.Bool("reminders", false, "migrate reminders")
|
|
blackWhiteLists = flag.Bool("blackWhite", false, "migrate black and white lists")
|
|
last = flag.Bool("last", false, "migrate last")
|
|
inventory = flag.Bool("inventory", false, "migrate inventory")
|
|
first = flag.Bool("first", false, "migrate first")
|
|
counter = flag.Bool("counter", false, "migrate counter")
|
|
apppass = flag.Bool("apppass", false, "migrate apppass")
|
|
nobabbler = flag.Bool("nobabbler", true, "don't migrate the babbler")
|
|
rmconfig = flag.Bool("rmconfig", false, "remove config")
|
|
|
|
all = flag.Bool("all", false, "migrate all")
|
|
)
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
|
|
db, err := sqlx.Open("sqlite", *dbPath)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
store, err := bh.Open(*storePath, 0666, &bh.Options{
|
|
Options: &bbolt.Options{
|
|
NoFreelistSync: true,
|
|
FreelistType: "hashmap",
|
|
NoSync: true,
|
|
},
|
|
})
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
if *rmconfig {
|
|
rmConfig(store)
|
|
return
|
|
}
|
|
|
|
if *fact || *all {
|
|
if err := migrateFacts(db, store); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
if *config {
|
|
if err := migrateConfig(db, store); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
if *babbler || *all && !*nobabbler {
|
|
if err := migrateBabbler(db, store); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
if *beers || *all {
|
|
if err := migrateBeers(db, store); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
if *awards || *all {
|
|
if err := migrateAwards(db, store); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
if *webshit || *all {
|
|
if err := migrateWebshit(db, store); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
if *wire || *all {
|
|
if err := migrateWires(db, store); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
if *tell || *all {
|
|
if err := migrateTell(db, store); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
if *sms || *all {
|
|
if err := migrateSMS(db, store); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
if *reminders || *all {
|
|
if err := migrateReminders(db, store); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
if *blackWhiteLists || *all {
|
|
if err := migrateBlackWhite(db, store); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
if *last || *all {
|
|
if err := migrateLast(db, store); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
if *inventory || *all {
|
|
if err := migrateInventory(db, store); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
if *first || *all {
|
|
if err := migrateFirst(db, store); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
if *counter || *all {
|
|
if err := migrateCounter(db, store); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
if *apppass || *all {
|
|
if err := migrateApppass(db, store); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
}
|