From 8bf060f71d434c7b3a70c929a18d658cc8b1f41d Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Thu, 19 Jan 2023 15:17:30 -0500 Subject: [PATCH] remove any frontend records assigned to an environment when the environment (#171) --- controller/disable.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/controller/disable.go b/controller/disable.go index 4e89cf1a..6db87126 100644 --- a/controller/disable.go +++ b/controller/disable.go @@ -117,6 +117,15 @@ func (h *disableHandler) removeEnvironment(envId int, tx *sqlx.Tx) error { return errors.Wrapf(err, "error deleting share '%d' for environment '%d'", shr.Id, envId) } } + fes, err := str.FindFrontendsForEnvironment(envId, tx) + if err != nil { + return errors.Wrapf(err, "error finding frontends for environment '%d'", envId) + } + for _, fe := range fes { + if err := str.DeleteFrontend(fe.Id, tx); err != nil { + return errors.Wrapf(err, "error deleting frontend '%d' for environment '%d'", fe.Id, envId) + } + } if err := str.DeleteEnvironment(envId, tx); err != nil { return errors.Wrapf(err, "error deleting environment '%d'", envId) }