Skip to content

Commit

Permalink
decoupled cron and the migration
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Sep 19, 2023
1 parent fe3cfca commit 5bcb005
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions server/backend/migration/20230530000000.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
_ "embed"
"time"

"github.com/TUM-Dev/Campus-Backend/server/backend/cron"
"github.com/TUM-Dev/Campus-Backend/server/model"
"github.com/go-gormigrate/gormigrate/v2"
"github.com/guregu/null"
Expand Down Expand Up @@ -39,14 +38,14 @@ func (m TumDBMigrator) migrate20230530000000() *gormigrate.Migration {
return err
}

err := SafeEnumMigrate(tx, model.Crontab{}, "type", cron.NewExamResultsHook)
err := SafeEnumMigrate(tx, model.Crontab{}, "type", "newExamResultsHook")
if err != nil {
return err
}

return tx.Create(&model.Crontab{
Interval: 60, // Every 5 minutes
Type: null.StringFrom(cron.NewExamResultsHook),
Type: null.StringFrom("newExamResultsHook"),
}).Error
},
Rollback: func(tx *gorm.DB) error {
Expand All @@ -57,12 +56,12 @@ func (m TumDBMigrator) migrate20230530000000() *gormigrate.Migration {
return err
}

err := SafeEnumRollback(tx, model.Crontab{}, "type", cron.NewExamResultsHook)
err := SafeEnumRollback(tx, model.Crontab{}, "type", "newExamResultsHook")
if err != nil {
return err
}

return tx.Delete(&model.Crontab{}, "type = ?", cron.NewExamResultsHook).Error
return tx.Delete(&model.Crontab{}, "type = ?", "newExamResultsHook").Error
},
}
}

0 comments on commit 5bcb005

Please sign in to comment.