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/reminder"
|
|
|
|
"log"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ReminderSQL struct {
|
|
|
|
reminder.Reminder
|
|
|
|
|
|
|
|
When string `db:"remindWhen"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func migrateReminders(db *sqlx.DB, store *bh.Store) error {
|
|
|
|
allReminders := []ReminderSQL{}
|
|
|
|
log.Printf("Migrating %T", allReminders)
|
|
|
|
if err := db.Select(&allReminders, `select * from reminders`); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, r := range allReminders {
|
|
|
|
rem := r.Reminder
|
|
|
|
rem.When, _ = time.Parse("2006-01-02 15:04:05", r.When)
|
2021-12-22 07:53:02 +00:00
|
|
|
if err := store.Insert(bh.NextSequence(), &rem); err != nil {
|
2021-12-22 03:36:08 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|