mirror of https://github.com/velour/catbase.git
32 lines
670 B
Go
32 lines
670 B
Go
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)
|
|
if err := store.Insert(bh.NextSequence(), &rem); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|