remove any frontend records assigned to an environment when the environment (#171)

This commit is contained in:
Michael Quigley 2023-01-19 15:17:30 -05:00
parent ea2e4c8a98
commit 8bf060f71d
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62

View File

@ -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)
}