From 34e40a8f15364e386fd73c69e4ef9aff28aff298 Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Sun, 6 Aug 2023 07:49:37 -0700 Subject: [PATCH] :bug: Fix dangling ruleset ref to image File. Signed-off-by: Jeff Ortel --- api/ruleset.go | 2 +- migration/v8/migrate.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/api/ruleset.go b/api/ruleset.go index c270171da..9b390f95b 100644 --- a/api/ruleset.go +++ b/api/ruleset.go @@ -121,7 +121,7 @@ func (h RuleSetHandler) Create(ctx *gin.Context) { _ = ctx.Error(err) return } - + h.Respond(ctx, http.StatusCreated, ruleset) } diff --git a/migration/v8/migrate.go b/migration/v8/migrate.go index e7fa1e5c6..e6034a70d 100644 --- a/migration/v8/migrate.go +++ b/migration/v8/migrate.go @@ -67,6 +67,21 @@ func (r Migration) Apply(db *gorm.DB) (err error) { return } } + err = db.Migrator().DropConstraint(&model.RuleSet{}, "fk_RuleSet_Image") + if err != nil { + err = liberr.Wrap(err) + return + } + err = db.Migrator().DropColumn(&model.RuleSet{}, "ImageID") + if err != nil { + err = liberr.Wrap(err) + return + } + err = db.Migrator().DropColumn(&model.RuleSet{}, "Custom") + if err != nil { + err = liberr.Wrap(err) + return + } return }