Skip to content

Commit c029df8

Browse files
committed
Return default views if database is invalid
This affects very few people, and better a quick fix for now.
1 parent c4e25f0 commit c029df8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

settings.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,21 @@ func (ss *UserSettings) Scan(v interface{}) error {
296296
}
297297
}
298298

299+
// This exists as a work-around because a migration set this column wrong >_<
300+
//
301+
// https://github.com/arp242/goatcounter/issues/569#issuecomment-1042013488
302+
func (w *Widgets) UnmarshalJSON(d []byte) error {
303+
type alias Widgets
304+
ww := alias(*w)
305+
err := json.Unmarshal(d, &ww)
306+
*w = Widgets(ww)
307+
308+
if err != nil {
309+
*w = defaultWidgets(context.Background())
310+
}
311+
return nil
312+
}
313+
299314
func (ss *SiteSettings) Defaults(ctx context.Context) {
300315
if ss.Campaigns == nil {
301316
ss.Campaigns = []string{"utm_campaign", "utm_source", "ref"}

0 commit comments

Comments
 (0)