Skip to content

Commit

Permalink
added a migration to remove the chat variabnt from the cronjob
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Sep 12, 2023
1 parent e13b8a9 commit 8689fd8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions server/backend/migration/20230825000000.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package migration

import (
"github.com/TUM-Dev/Campus-Backend/server/model"
"github.com/go-gormigrate/gormigrate/v2"
"gorm.io/gorm"
)

// migrate20230825000000
// Removes the ability to run chat cronjobs
func (m TumDBMigrator) migrate20230825000000() *gormigrate.Migration {

Check failure on line 11 in server/backend/migration/20230825000000.go

View workflow job for this annotation

GitHub Actions / lint

func `TumDBMigrator.migrate20230825000000` is unused (unused)
return &gormigrate.Migration{
ID: "20230825000000",
Migrate: func(tx *gorm.DB) error {
// deactivete the crontab (Rollback deletes this from the enum)
// given that previously, not cronjobs for this type existed there is no need to remove offending entries first
return SafeEnumRollback(tx, &model.Crontab{}, "type", "chat")
},
Rollback: func(tx *gorm.DB) error {
// activete the crontab (Migrate adds this from to the enum)
// given that previously, not cronjobs for this type existed there is no need to add entries first
return SafeEnumMigrate(tx, &model.Crontab{}, "type", "chat")
},
}
}
2 changes: 1 addition & 1 deletion server/model/crontab.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Crontab struct {
//[ 2] lastRun int null: false primary: false isArray: false auto: false col: int len: -1 default: [0]
LastRun int32 `gorm:"column:lastRun;type:int;default:0;" json:"last_run"`
//[ 3] type char(10) null: true primary: false isArray: false auto: false col: char len: 10 default: []
Type null.String `gorm:"column:type;type:enum ('news', 'mensa', 'chat', 'kino', 'roomfinder', 'alarm', 'fileDownload','dishNameDownload','averageRatingComputation', 'iosNotifications', 'iosActivityReset', 'canteenHeadCount');" json:"type"`
Type null.String `gorm:"column:type;type:enum ('news', 'mensa', 'kino', 'roomfinder', 'alarm', 'fileDownload','dishNameDownload','averageRatingComputation', 'iosNotifications', 'iosActivityReset', 'canteenHeadCount');" json:"type"`
//[ 4] id int null: true primary: false isArray: false auto: false col: int len: -1 default: []
ID null.Int `gorm:"column:id;type:int;" json:"id"`
}

0 comments on commit 8689fd8

Please sign in to comment.