2022-09-10 11:39:07 +00:00
|
|
|
package v2migrator
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
|
2022-10-22 22:08:02 +00:00
|
|
|
"github.com/Luzifer/twitch-bot/internal/apimodules/overlays"
|
2022-09-10 11:39:07 +00:00
|
|
|
"github.com/Luzifer/twitch-bot/pkg/database"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
storageModOverlays struct {
|
2022-10-22 22:08:02 +00:00
|
|
|
ChannelEvents map[string][]overlays.SocketMessage `json:"channel_events"`
|
2022-09-10 11:39:07 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s storageModOverlays) migrate(db database.Connector) (err error) {
|
|
|
|
for channel, evts := range s.ChannelEvents {
|
|
|
|
for _, evt := range evts {
|
2022-10-22 22:08:02 +00:00
|
|
|
if err := overlays.AddChannelEvent(db, channel, evt); err != nil {
|
2022-09-10 11:39:07 +00:00
|
|
|
return errors.Wrap(err, "storing event to database")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|