fix: assume coding as default category if not specified otherwise (see #817)

This commit is contained in:
Ferdinand Mütsch
2025-08-02 11:06:39 +02:00
parent 7f281184de
commit 8b8fe21fed
3 changed files with 382 additions and 337 deletions

View File

@@ -0,0 +1,30 @@
package migrations
import (
"github.com/muety/wakapi/config"
"gorm.io/gorm"
)
// see https://github.com/muety/wakapi/issues/817#issuecomment-3146365708
func init() {
const name = "20250802_fix_default_coding_category"
f := migrationFunc{
name: name,
background: true,
f: func(db *gorm.DB, cfg *config.Config) error {
if hasRun(name, db) {
return nil
}
if err := db.Exec("update heartbeats set category = 'coding' where category = '' and type = 'file' and language != ''").Error; err != nil {
return err
}
setHasRun(name, db)
return nil
},
}
registerPostMigration(f)
}