From e13b8a96282d8b47435a0b7341f41d6605b5cbd6 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Sat, 26 Aug 2023 20:08:22 +0200 Subject: [PATCH 1/3] removed all components --- server/backend/cron/chat.go | 7 ------- server/backend/cron/cronjobs.go | 3 --- 2 files changed, 10 deletions(-) delete mode 100644 server/backend/cron/chat.go diff --git a/server/backend/cron/chat.go b/server/backend/cron/chat.go deleted file mode 100644 index 5f6498f1..00000000 --- a/server/backend/cron/chat.go +++ /dev/null @@ -1,7 +0,0 @@ -package cron - -//lint:ignore U1000 stub -func (c *CronService) chatCron() error { - // TODO: implement - return nil -} diff --git a/server/backend/cron/cronjobs.go b/server/backend/cron/cronjobs.go index 1316f575..fc6858b9 100644 --- a/server/backend/cron/cronjobs.go +++ b/server/backend/cron/cronjobs.go @@ -31,7 +31,6 @@ const ( IOSActivityReset = "iosActivityReset" /* MensaType = "mensa" - ChatType = "chat" KinoType = "kino" RoomfinderType = "roomfinder" AlarmType = "alarm" */ @@ -107,8 +106,6 @@ func (c *CronService) Run() error { TODO: Implement handlers for other cronjobs case MensaType: g.Go(func() error { return c.mensaCron() }) - case ChatType: - g.Go(func() error { return c.chatCron() }) case KinoType: g.Go(func() error { return c.kinoCron() }) case RoomfinderType: From 8689fd8e00fda020e155746abde54fdce376131e Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Sat, 26 Aug 2023 20:08:32 +0200 Subject: [PATCH 2/3] added a migration to remove the chat variabnt from the cronjob --- server/backend/migration/20230825000000.go | 25 ++++++++++++++++++++++ server/model/crontab.go | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 server/backend/migration/20230825000000.go diff --git a/server/backend/migration/20230825000000.go b/server/backend/migration/20230825000000.go new file mode 100644 index 00000000..6f64ea82 --- /dev/null +++ b/server/backend/migration/20230825000000.go @@ -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 { + 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") + }, + } +} diff --git a/server/model/crontab.go b/server/model/crontab.go index e42571b2..a4506833 100644 --- a/server/model/crontab.go +++ b/server/model/crontab.go @@ -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"` } From 97b089b85f376db1dbd4474ecde83b5b14d69000 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Tue, 12 Sep 2023 21:34:51 +0200 Subject: [PATCH 3/3] added the missing migration to the list of migrations --- server/backend/migration/migration.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/backend/migration/migration.go b/server/backend/migration/migration.go index b5511a82..1613c268 100644 --- a/server/backend/migration/migration.go +++ b/server/backend/migration/migration.go @@ -42,6 +42,7 @@ func (m TumDBMigrator) Migrate() error { m.migrate20221119131300(), m.migrate20221210000000(), m.migrate20230904000000(), + m.migrate20230825000000(), }) err := mig.Migrate() return err